Esempio n. 1
0
void
plD_esc_xfig(PLStream *pls, PLINT op, void *ptr)
{
  PLDev *dev = pls->dev;
  int i, npts;
 
  switch (op) { 
  case PLESC_FILL:

    npts = pls->dev_npts;
    if (npts > PL_MAXPOLY)
      plexit("FillPolygonCmd: Too many points in polygon\n");
     
    flushbuffer(pls);
    fprintf(pls->OutFile, "2 1 0 1 %d %d 50 0 20 0.0 0 0 0 0 0 %d\n",
	    curcol, curcol, npts);

    for (i = 0; i < npts; i++)
      fprintf(pls->OutFile,"%d %d ",  pls->dev_x[i],
	      offset + dev->ymax * (int)dev->xscale_dev - pls->dev_y[i]);

    fprintf(pls->OutFile, "\n");
    break;

  case PLESC_HAS_TEXT:
    proc_str(pls, ptr);
    break;
  }  
}
Esempio n. 2
0
static
int test_rfork1(int idx, struct bproc_test_info_t *inf) {
    int err, i;
#if 0
    int cc, ncc, lw;		/* ACTUAL values */
    int c_cc, c_ncc, c_lw;	/* CORRECT values */
#endif

    printf(" ppid=%d(%d)", getpid(), bproc_currnode()); fflush(stdout);
    for (i=1; i < inf->nprocs; i++) {
	inf->pid[i] = bproc_rfork(inf->node[i]);
	if (inf->pid[i] < 0) {
	    fprintf(stderr, "bproc_rfork(%d): %s\n", inf->pid[i],
		    bproc_strerror(errno));
	    exit(1);
	}
	if (inf->pid[i] == 0) {
	    /* CHILD */
	    exit(0);
	}
	printf(" pid=%d", inf->pid[i]); fflush(stdout);
    }

#if 0
    /* This sanity check is broken */

    /* Sanity check our process tree */
    cc  = child_count();
    ncc = nlchild_count();
    lw  = local_wait(0);
    
    c_cc  = 2;
    c_ncc = (inf->pid[0] == inf->pid[1] || inf->pid[0] == -1) ? 0 : 2;
    c_lw  = (inf->pid[0] == inf->pid[1] || inf->pid[0] == -1) ? 1 : 0;
    

    if ((cc != c_cc) || (ncc != c_ncc) || (lw != c_lw)) {
	printf("\nProcess State:\n");
	printf("                  kern  mine\n"); 
	printf("  child_count   = %-4d  %d%s\n", cc, c_cc,
	       cc != c_cc ? "  ** MISMATCH **":"");
	printf("  nlchild_count = %-4d  %d%s\n", ncc, c_ncc,
	       ncc != c_ncc ? "  ** MISMATCH **":"");
	printf("  local_wait    = %-4d  %d%s\n", lw, c_lw,
	       lw != c_lw ? "  ** MISMATCH **":"");
	for (i=1; i < inf->nprocs; i++)
	    printf("  ch[%d]=%d(%s)", i,
		   inf->pid[i], proc_str(proc_arr(inf->arr,i)));
	printf("\n");
    }
#endif
    err = 0;
    for (i=1; i < inf->nprocs; i++) {
	if (wait(0) < 0) {
	    printf("wait: %s", strerror(errno));
	    err = 1;
	}
    }
    exit(err);
}
Esempio n. 3
0
void
plD_esc_ps(PLStream *pls, PLINT op, void *ptr)
{
    switch (op) {
    case PLESC_FILL:
      fill_polygon(pls);
      break;
    case PLESC_HAS_TEXT:
      proc_str(pls, (EscText *)ptr);
      break;
    }
}
Esempio n. 4
0
static
void wait_data_check(struct bproc_test_info_t *info, int wpid) {
    int i, err, a; 
    int ccount, nlcount, lwait;
    int knlcount, kccount, klwait;
    int retry=0;

    a = proc_arr(info->arr,0);
    
    /* If parent is not on front end, do a bunch of process tree checking */
    if (a != proc_fe) {
    try_again:
	ccount = 0;
	nlcount = 0;
	lwait = 1;
	/* Check up on BProc's book keeping of our children... */
	for (i=1; i < info->nprocs; i++) {
	    if (info->pid[i]) {
		a = proc_arr(info->arr,i);
		if (proc_isdetach(a) && !(info->scratch & (1<<i)))
		    continue;
		ccount++;
		if (!proc_samenode(a,proc_arr(info->arr,0))) {
		    nlcount++;
		    if (info->pid[i] == wpid || wpid == -1) lwait = 0;
		}
	    }
	}

	/* Ask the kernel for the same info */
	knlcount = nlchild_count();
	kccount  = child_count();
	klwait   = local_wait(wpid);
	err = kccount != ccount || knlcount != nlcount || klwait != lwait;
	if (err) {
	    /* It is possible that we'll end up looking at these
	     * values a bit too soon - before something has finished
	     * moving or before a masq process has finished cleaning
	     * itself up.  In that case, our child_count should still
	     * be correct but the others may be off.  If that's the
	     * case, retry a few times.  Really, the debug stuff
	     * should be fixed to atomically return all of that. */
	    if (kccount == ccount && retry < MAX_RETRY/RETRY_DELAY ) {
		usleep(RETRY_DELAY);
		retry ++;
		goto try_again;
	    }

	    printf("\nProcess State:\n");
	    printf("                  kern  mine\n"); 
	    printf("  child_count   = %-4d  %d%s\n", kccount, ccount,
		   kccount != ccount ? "  ** MISMATCH **":"");
	    printf("  nlchild_count = %-4d  %d%s\n", knlcount, nlcount,
		   knlcount != nlcount ? "  ** MISMATCH **":"");
	    printf("  local_wait    = %-4d  %d%s\n", klwait, lwait,
		   klwait != lwait ? "  ** MISMATCH **":"");
	    printf("  wpid=%d  mynode=%s",
		   wpid, proc_str(proc_arr(info->arr,0)));
	    for (i=1; i < info->nprocs; i++)
		printf("  ch[%d]=%d(%s)", i,
		       info->pid[i], proc_str(proc_arr(info->arr,i)));
	    printf("\n");
	    if (err) sleep(10000);
	}
    }

    check_tree();
}