--- ray/src/rt/rpict.c 1992/11/19 20:25:57 2.20 +++ ray/src/rt/rpict.c 1993/01/29 12:15:40 2.23 @@ -27,6 +27,12 @@ static char SCCSid[] = "$SunId$ LBL"; #include "paths.h" +#define RFTEMPLATE "rfXXXXXX" + +#ifndef SIGCONT +#define SIGCONT SIGIO +#endif + int dimlist[MAXDIM]; /* sampling dimensions */ int ndims = 0; /* number of sampling dimensions */ int samplendx; /* sample index number */ @@ -82,12 +88,6 @@ extern long nrays; /* number of rays traced */ #define pixjitter() (.5+dstrpix*(.5-frandom())) -#define RFTEMPLATE "rfXXXXXX" -#define HFTEMPLATE TEMPLATE - -static char *hfname = NULL; /* header file name */ -static FILE *hfp = NULL; /* header file pointer */ - static int hres, vres; /* resolution for this frame */ extern char *mktemp(); @@ -100,11 +100,8 @@ int code; { if (code) /* report status */ report(); - if (hfname != NULL) { /* delete header file */ - if (hfp != NULL) - fclose(hfp); - unlink(hfname); - } + headclean(); /* delete header file */ + pfclean(); /* clean up persist files */ exit(code); } @@ -134,38 +131,11 @@ report() /* report progress */ sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n", nrays, pctdone, (tlastrept-tstart)/3600.0); eputs(errmsg); - signal(SIGALRM, report); + signal(SIGCONT, report); } #endif -openheader() /* save standard output to header file */ -{ - hfname = mktemp(HFTEMPLATE); - if (freopen(hfname, "w", stdout) == NULL) { - sprintf(errmsg, "cannot open header file \"%s\"", hfname); - error(SYSTEM, errmsg); - } -} - - -dupheader() /* repeat header on standard output */ -{ - register int c; - - if (hfp == NULL) { - if ((hfp = fopen(hfname, "r")) == NULL) - error(SYSTEM, "error reopening header file"); -#ifdef MSDOS - setmode(fileno(hfp), O_BINARY); -#endif - } else if (fseek(hfp, 0L, 0) < 0) - error(SYSTEM, "seek error on header file"); - while ((c = getc(hfp)) != EOF) - putchar(c); -} - - rpict(seq, pout, zout, prvr) /* generate image(s) */ int seq; char *pout, *zout, *prvr; @@ -181,7 +151,7 @@ char *pout, *zout, *prvr; * sequenced file naming. */ { - extern char *rindex(), *strncpy(), *strcat(); + extern char *rindex(), *strncpy(), *strcat(), *strcpy(); char fbuf[128], fbuf2[128]; register char *cp; RESOLU rs; @@ -358,7 +328,7 @@ char *zfile, *oldfile; #ifndef BSD else #endif - signal(SIGALRM, report); + signal(SIGCONT, report); ypos = vres-1 - i; fillscanline(scanbar[0], zbar[0], sampdens, hres, ypos, hstep); /* compute scanlines */ @@ -381,7 +351,7 @@ char *zfile, *oldfile; fillscanbar(scanbar, zbar, hres, ypos, ystep); /* write it out */ #ifndef BSD - signal(SIGALRM, SIG_IGN); /* don't interrupt writes */ + signal(SIGCONT, SIG_IGN); /* don't interrupt writes */ #endif for (i = ystep; i > 0; i--) { if (zfd != -1 && write(zfd, (char *)zbar[i], @@ -399,11 +369,11 @@ char *zfile, *oldfile; report(); #ifndef BSD else - signal(SIGALRM, report); + signal(SIGCONT, report); #endif } /* clean up */ - signal(SIGALRM, SIG_IGN); + signal(SIGCONT, SIG_IGN); if (zfd != -1) { if (write(zfd, (char *)zbar[0], hres*sizeof(float)) < hres*sizeof(float)) @@ -423,6 +393,7 @@ char *zfile, *oldfile; pctdone = 100.0; if (ralrm > 0) report(); + signal(SIGCONT, SIG_DFL); return; writerr: error(SYSTEM, "write error in render");