ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rholo.c
Revision: 3.50
Committed: Tue Mar 9 08:51:39 1999 UTC (25 years, 1 month ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 3.49: +3 -4 lines
Log Message:
removed unnecessary inclusion of sys/types.h

File Contents

# User Rev Content
1 gwlarson 3.46 /* Copyright (c) 1999 Silicon Graphics, Inc. */
2 gregl 3.1
3     #ifndef lint
4     static char SCCSid[] = "$SunId$ SGI";
5     #endif
6    
7     /*
8     * Radiance holodeck generation controller
9     */
10    
11     #include "rholo.h"
12 gregl 3.14 #include "random.h"
13 gregl 3.12 #include <signal.h>
14     #include <sys/stat.h>
15 gregl 3.1
16 gwlarson 3.44 #ifndef FRAGWARN
17     #define FRAGWARN 20 /* fragmentation for warning (%) */
18     #endif
19 gregl 3.33 #ifndef MAXQTIME
20     #define MAXQTIME 5 /* target maximum seconds in queue */
21     #endif
22 gwlarson 3.49 /* manual cache flushing frequency */
23     #ifndef RTFLUSH
24     #if MAXQTIME
25     #define RTFLUSH (300/MAXQTIME*totqlen) /* <= 5 minutes */
26     #else
27     #define RTFLUSH (50*totqlen) /* just guess */
28     #endif
29     #endif
30 gregl 3.1 /* the following must be consistent with rholo.h */
31     int NVARS = NRHVARS; /* total number of variables */
32    
33     VARIABLE vv[] = RHVINIT; /* variable-value pairs */
34    
35     char *progname; /* our program name */
36     char *hdkfile; /* holodeck file name */
37 gregl 3.22 char froot[256]; /* root file name */
38 gregl 3.1
39     int ncprocs = 0; /* desired number of compute processes */
40    
41     char *outdev = NULL; /* output device name */
42    
43 gregl 3.17 int readinp = 0; /* read commands from stdin */
44    
45 gregl 3.20 int force = 0; /* allow overwrite of holodeck */
46    
47 gregl 3.1 time_t starttime; /* time we got started */
48     time_t endtime; /* time we should end by */
49     time_t reporttime; /* time for next report */
50    
51 gregl 3.8 long maxdisk; /* maximum file space (bytes) */
52    
53 gregl 3.1 int rtargc = 1; /* rtrace command */
54     char *rtargv[128] = {"rtrace", NULL};
55    
56 gregl 3.12 int orig_mode = -1; /* original file mode (-1 if unchanged) */
57    
58 gregl 3.1 long nraysdone = 0L; /* number of rays done */
59     long npacksdone = 0L; /* number of packets done */
60    
61     PACKET *freepacks; /* available packets */
62 gwlarson 3.49 int totqlen; /* maximum queue length (number of packets) */
63 gregl 3.1
64 gregl 3.12 char *sigerr[NSIG]; /* signal error messages */
65    
66 gwlarson 3.40 extern int nowarn; /* turn warnings off? */
67    
68 gregl 3.1 extern time_t time();
69    
70    
71     main(argc, argv)
72     int argc;
73     char *argv[];
74     {
75     int i;
76 gregl 3.33
77 gregl 3.18 initurand(16384); /* initialize urand */
78 gregl 3.1 progname = argv[0]; /* get arguments */
79     for (i = 1; i < argc && argv[i][0] == '-'; i++)
80     switch (argv[i][1]) {
81     case 'w': /* turn off warnings */
82     nowarn++;
83     break;
84     case 'f': /* force overwrite */
85     force++;
86     break;
87 gregl 3.17 case 'i': /* read input from stdin */
88     readinp++;
89     break;
90 gregl 3.1 case 'n': /* compute processes */
91     if (i >= argc-2)
92     goto userr;
93     ncprocs = atoi(argv[++i]);
94     break;
95     case 'o': /* output display */
96     if (i >= argc-2)
97     goto userr;
98     outdev = argv[++i];
99     break;
100     default:
101     goto userr;
102     }
103     /* get root file name */
104 gregl 3.32 if (i >= argc)
105     goto userr;
106 gregl 3.1 rootname(froot, hdkfile=argv[i++]);
107 gregl 3.27 /* load variables? */
108     if (i < argc)
109     if (argv[i][0] != '-' && argv[i][0] != '+')
110     loadvars(argv[i]); /* load variables from file */
111    
112     if (i >= argc || argv[i][0] == '+')
113     loadholo(); /* load existing holodeck */
114    
115     while (++i < argc) /* get command line settings */
116     if (setvariable(argv[i], matchvar) < 0) {
117     sprintf(errmsg, "unknown variable: %s", argv[i]);
118     error(USER, errmsg);
119     }
120     /* check settings */
121     checkvalues();
122 gregl 3.36 /* load rad input file */
123     getradfile();
124 gregl 3.27
125 gregl 3.28 if (hdlist[0] == NULL) { /* create new holodeck */
126 gregl 3.29 HDGRID hdg[HDMAX];
127 gregl 3.1 /* set defaults */
128 gregl 3.29 setdefaults(hdg);
129 gregl 3.1 /* holodeck exists? */
130     if (!force && access(hdkfile, R_OK|W_OK) == 0)
131     error(USER,
132     "holodeck file exists -- use -f to overwrite");
133     /* create holodeck */
134 gregl 3.29 creatholo(hdg);
135 gregl 3.27 } else /* else just set defaults */
136 gregl 3.15 setdefaults(NULL);
137 gregl 3.1 /* initialize */
138     initrholo();
139 gregl 3.15 /* main loop */
140 gregl 3.1 while (rholo())
141     ;
142     /* done */
143     quit(0);
144     userr:
145     fprintf(stderr,
146 gregl 3.27 "Usage: %s [-n nprocs][-o disp][-w][-f] output.hdk [control.hif|+|- [VAR=val ..]]\n",
147 gregl 3.1 progname);
148     quit(1);
149     }
150    
151    
152 gregl 3.12 onsig(signo) /* fatal signal */
153     int signo;
154     {
155     static int gotsig = 0;
156    
157 gwlarson 3.47 if (gotsig > 1) /* we're going as fast as we can! */
158     return;
159     if (gotsig++) { /* two signals and we split */
160     hdsync(NULL, 0); /* don't leave w/o saying goodbye */
161 gregl 3.12 _exit(signo);
162 gwlarson 3.47 }
163     alarm(300); /* allow 5 minutes to clean up */
164 gregl 3.12 eputs("signal - ");
165     eputs(sigerr[signo]);
166     eputs("\n");
167     quit(3);
168     }
169    
170    
171     sigdie(signo, msg) /* set fatal signal */
172     int signo;
173     char *msg;
174     {
175     if (signal(signo, onsig) == SIG_IGN)
176     signal(signo, SIG_IGN);
177     sigerr[signo] = msg;
178     }
179    
180    
181     int
182     resfmode(fd, mod) /* restrict open file access mode */
183     int fd, mod;
184     {
185     struct stat stbuf;
186     /* get original mode */
187     if (fstat(fd, &stbuf) < 0)
188     error(SYSTEM, "cannot stat open holodeck file");
189     mod &= stbuf.st_mode; /* always more restrictive */
190 gregl 3.35 if (mod == (stbuf.st_mode & 0777))
191 gregl 3.12 return(-1); /* already set */
192     /* else change it */
193     if (fchmod(fd, mod) < 0) {
194     error(WARNING, "cannot change holodeck file access mode");
195     return(-1);
196     }
197     return(stbuf.st_mode); /* return original mode */
198     }
199    
200    
201 gregl 3.1 initrholo() /* get our holodeck running */
202     {
203     extern int global_packet();
204     register int i;
205 gregl 3.17 /* close holodeck on exec() */
206     fcntl(hdlist[0]->fd, F_SETFD, FD_CLOEXEC);
207 gregl 3.4
208     if (outdev != NULL) /* open output device */
209     disp_open(outdev);
210 gregl 3.1 else if (ncprocs > 0) /* else use global ray feed */
211     init_global();
212 gregl 3.8 /* record disk space limit */
213     if (!vdef(DISKSPACE))
214     maxdisk = 0;
215     else
216 gregl 3.9 maxdisk = 1024.*1024.*vflt(DISKSPACE);
217 gregl 3.1 /* set up memory cache */
218 gregl 3.5 if (outdev == NULL)
219 gwlarson 3.50 hdcachesize = 0; /* manual flushing */
220 gregl 3.5 else if (vdef(CACHE))
221     hdcachesize = 1024.*1024.*vflt(CACHE);
222 gregl 3.1 /* open report file */
223     if (vdef(REPORT)) {
224     register char *s = sskip2(vval(REPORT), 1);
225     if (*s && freopen(s, "a", stderr) == NULL)
226     quit(2);
227     }
228 gregl 3.33 /* mark the starting time */
229     starttime = time(NULL);
230     /* compute end time */
231     if (!vdef(TIME) || vflt(TIME) <= FTINY)
232     endtime = 0;
233     else
234     endtime = starttime + vflt(TIME)*3600. + .5;
235 gregl 3.1 /* start rtrace */
236     if (ncprocs > 0) {
237 gwlarson 3.38 totqlen = i = start_rtrace();
238 gregl 3.1 if (i < 1)
239 gregl 3.20 error(USER, "cannot start rtrace process(es)");
240 gregl 3.1 if (vdef(REPORT)) { /* make first report */
241     printargs(rtargc, rtargv, stderr);
242     report(0);
243     }
244     /* allocate packets */
245     freepacks = (PACKET *)bmalloc(i*sizeof(PACKET));
246     if (freepacks == NULL)
247     goto memerr;
248     freepacks[--i].nr = 0;
249     freepacks[i].next = NULL;
250 gregl 3.25 if (!vdef(OBSTRUCTIONS) || !vbool(OBSTRUCTIONS)) {
251 gregl 3.1 freepacks[i].offset = (float *)bmalloc(
252     RPACKSIZ*sizeof(float)*(i+1) );
253     if (freepacks[i].offset == NULL)
254     goto memerr;
255     } else
256     freepacks[i].offset = NULL;
257     while (i--) {
258     freepacks[i].nr = 0;
259     freepacks[i].offset = freepacks[i+1].offset == NULL ?
260     NULL : freepacks[i+1].offset+RPACKSIZ ;
261     freepacks[i].next = &freepacks[i+1];
262     }
263     }
264 gregl 3.12 /* set up signal handling */
265     sigdie(SIGINT, "Interrupt");
266     sigdie(SIGHUP, "Hangup");
267     sigdie(SIGTERM, "Terminate");
268     sigdie(SIGPIPE, "Broken pipe");
269     sigdie(SIGALRM, "Alarm clock");
270     #ifdef SIGXCPU
271     sigdie(SIGXCPU, "CPU limit exceeded");
272     sigdie(SIGXFSZ, "File size exceeded");
273     #endif
274 gwlarson 3.50 /* protect holodeck file */
275 gregl 3.12 orig_mode = resfmode(hdlist[0]->fd, ncprocs>0 ? 0 : 0444);
276 gregl 3.1 return;
277     memerr:
278     error(SYSTEM, "out of memory in initrholo");
279     }
280    
281    
282     rholo() /* holodeck main loop */
283     {
284 gwlarson 3.44 static long nextfragwarn = 100*(1L<<20);
285 gregl 3.30 static int idle = 0;
286 gregl 3.1 PACKET *pl = NULL, *plend;
287 gwlarson 3.44 long fsiz;
288 gregl 3.33 int pksiz;
289 gregl 3.1 register PACKET *p;
290     time_t t;
291 gregl 3.30 /* check display */
292     if (nprocs <= 0)
293     idle = 1;
294     if (outdev != NULL) {
295 gregl 3.4 if (!disp_check(idle))
296 gregl 3.30 return(0); /* quit request */
297     if (nprocs <= 0)
298     return(1);
299     } else if (idle)
300     return(0); /* all done */
301 gwlarson 3.44 fsiz = hdfilen(hdlist[0]->fd); /* check file size */
302     if (maxdisk > 0 && fsiz >= maxdisk) {
303 gregl 3.8 error(WARNING, "file limit exceeded");
304 gregl 3.21 done_rtrace();
305     return(1); /* comes back */
306 gregl 3.8 }
307 gwlarson 3.44 #if FRAGWARN
308     if (fsiz >= nextfragwarn &&
309     (fsiz-hdfiluse(hdlist[0]->fd,0))/(fsiz/100) > FRAGWARN) {
310     sprintf(errmsg, "holodeck file fragmentation is %.0f%%",
311     100.*(fsiz-hdfiluse(hdlist[0]->fd,1))/fsiz);
312     error(WARNING, errmsg);
313     nextfragwarn = fsiz + (fsiz>>2); /* decent interval */
314     }
315     #endif
316 gregl 3.33 t = time(NULL); /* check time */
317 gregl 3.8 if (endtime > 0 && t >= endtime) {
318     error(WARNING, "time limit exceeded");
319 gregl 3.21 done_rtrace();
320     return(1); /* comes back */
321 gregl 3.8 }
322 gregl 3.3 if (reporttime > 0 && t >= reporttime)
323 gregl 3.1 report(t);
324 gregl 3.33 /* figure out good packet size */
325 gwlarson 3.48 pksiz = RPACKSIZ;
326 gregl 3.33 #if MAXQTIME
327 gwlarson 3.48 if (!chunkycmp) {
328     pksiz = nraysdone*MAXQTIME/(totqlen*(t - starttime + 1L));
329     if (pksiz < 1) pksiz = 1;
330     else if (pksiz > RPACKSIZ) pksiz = RPACKSIZ;
331     }
332 gregl 3.33 #endif
333 gregl 3.28 idle = 0; /* get packets to process */
334 gregl 3.1 while (freepacks != NULL) {
335     p = freepacks; freepacks = p->next; p->next = NULL;
336 gregl 3.33 if (!next_packet(p, pksiz)) {
337 gregl 3.1 p->next = freepacks; freepacks = p;
338 gregl 3.21 idle = 1;
339 gregl 3.1 break;
340     }
341     if (pl == NULL) pl = p;
342     else plend->next = p;
343     plend = p;
344     }
345 gregl 3.21 /* process packets */
346 gregl 3.1 done_packets(do_packets(pl));
347     return(1); /* and continue */
348     }
349    
350    
351     setdefaults(gp) /* set default values */
352     register HDGRID *gp;
353     {
354     extern char *atos();
355     register int i;
356 gregl 3.29 int n;
357 gregl 3.37 double len[3], d;
358 gregl 3.1 char buf[64];
359    
360     if (!vdef(SECTION)) {
361     sprintf(errmsg, "%s must be defined", vnam(SECTION));
362     error(USER, errmsg);
363     }
364     if (!vdef(OCTREE)) {
365     if ((vval(OCTREE) = bmalloc(strlen(froot)+5)) == NULL)
366     error(SYSTEM, "out of memory");
367     sprintf(vval(OCTREE), "%s.oct", froot);
368     vdef(OCTREE)++;
369 gregl 3.14 }
370     if (!vdef(VDIST)) {
371     vval(VDIST) = "F";
372     vdef(VDIST)++;
373 gregl 3.1 }
374     /* append rendering options */
375     if (vdef(RENDER))
376     rtargc += wordstring(rtargv+rtargc, vval(RENDER));
377 gregl 3.15
378     if (gp == NULL) /* already initialized? */
379     return;
380     /* set grid parameters */
381 gregl 3.29 for (n = 0; n < vdef(SECTION); n++, gp++) {
382     gp->grid[0] = gp->grid[1] = gp->grid[2] = 0;
383     if (sscanf(nvalue(SECTION, n),
384 gregl 3.16 "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %hd %hd %hd",
385 gregl 3.29 &gp->orig[0], &gp->orig[1], &gp->orig[2],
386     &gp->xv[0][0], &gp->xv[0][1], &gp->xv[0][2],
387     &gp->xv[1][0], &gp->xv[1][1], &gp->xv[1][2],
388     &gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2],
389     &gp->grid[0], &gp->grid[1], &gp->grid[2]) < 12)
390     badvalue(SECTION);
391     for (i = 0; i < 3; i++)
392 gregl 3.37 len[i] = VLEN(gp->xv[i]);
393     if (!vdef(GRID)) {
394 gwlarson 3.43 d = 2/2e5*( len[0]*len[0]*(len[1]*len[1] +
395 gregl 3.37 len[2]*len[2] + 4*len[1]*len[2])
396     + len[1]*len[1]*len[2]*(len[2] + 4*len[0])
397     + 4*len[0]*len[1]*len[2]*len[2] );
398     d = sqrt(sqrt(d));
399     } else if ((d = vflt(GRID)) <= FTINY)
400 gregl 3.29 badvalue(GRID);
401     for (i = 0; i < 3; i++)
402     if (gp->grid[i] <= 0)
403     gp->grid[i] = len[i]/d + (1.-FTINY);
404 gregl 3.15 }
405 gregl 3.1 }
406    
407    
408     creatholo(gp) /* create a holodeck output file */
409     HDGRID *gp;
410     {
411 gregl 3.12 extern char VersionID[];
412 gregl 3.29 int4 lastloc, nextloc;
413     int n;
414 gregl 3.10 int fd;
415 gregl 3.1 FILE *fp;
416     /* open & truncate file */
417     if ((fp = fopen(hdkfile, "w+")) == NULL) {
418     sprintf(errmsg, "cannot open \"%s\" for writing", hdkfile);
419     error(SYSTEM, errmsg);
420     }
421     /* write information header */
422     newheader("RADIANCE", fp);
423 gregl 3.12 fprintf(fp, "SOFTWARE= %s\n", VersionID);
424 gregl 3.1 printvars(fp);
425     fputformat(HOLOFMT, fp);
426     fputc('\n', fp);
427 gregl 3.29 putw(HOLOMAGIC, fp); /* put magic number */
428 gregl 3.10 fd = dup(fileno(fp));
429     fclose(fp); /* flush and close stdio stream */
430 gregl 3.29 lastloc = lseek(fd, 0L, 2);
431     for (n = vdef(SECTION); n--; gp++) { /* initialize each section */
432     nextloc = 0L;
433     write(fd, (char *)&nextloc, sizeof(nextloc));
434     hdinit(fd, gp); /* writes beam index */
435     if (!n)
436     break;
437     nextloc = hdfilen(fd); /* write section pointer */
438     if (lseek(fd, (long)lastloc, 0) < 0)
439     error(SYSTEM,
440     "cannot seek on holodeck file in creatholo");
441     write(fd, (char *)&nextloc, sizeof(nextloc));
442     lseek(fd, (long)(lastloc=nextloc), 0);
443     }
444 gregl 3.1 }
445    
446    
447 gwlarson 3.42 int
448 gregl 3.1 headline(s) /* process information header line */
449     char *s;
450     {
451     extern char FMTSTR[];
452     register char *cp;
453     char fmt[32];
454    
455 gregl 3.2 if (formatval(fmt, s)) {
456 gregl 3.1 if (strcmp(fmt, HOLOFMT)) {
457     sprintf(errmsg, "%s file \"%s\" has %s%s",
458     HOLOFMT, hdkfile, FMTSTR, fmt);
459     error(USER, errmsg);
460     }
461 gwlarson 3.42 return(0);
462 gregl 3.1 }
463     for (cp = s; *cp; cp++) /* take off any comments */
464     if (*cp == '#') {
465     *cp = '\0';
466     break;
467     }
468     setvariable(s, matchvar); /* don't flag errors */
469 gwlarson 3.42 return(0);
470 gregl 3.1 }
471    
472    
473     loadholo() /* start loading a holodeck from fname */
474     {
475 gregl 3.10 extern long ftell();
476 gregl 3.1 FILE *fp;
477 gregl 3.10 int fd;
478 gregl 3.29 int n;
479     int4 nextloc;
480 gregl 3.4 /* open holodeck file */
481     if ((fp = fopen(hdkfile, ncprocs>0 ? "r+" : "r")) == NULL) {
482 gwlarson 3.39 sprintf(errmsg, "cannot %s \"%s\"",
483     ncprocs>0 ? "append" : "read", hdkfile);
484 gregl 3.1 error(SYSTEM, errmsg);
485     }
486     /* load variables from header */
487     getheader(fp, headline, NULL);
488     /* check magic number */
489     if (getw(fp) != HOLOMAGIC) {
490     sprintf(errmsg, "bad magic number in holodeck file \"%s\"",
491     hdkfile);
492     error(USER, errmsg);
493     }
494 gregl 3.29 nextloc = ftell(fp); /* get stdio position */
495 gregl 3.10 fd = dup(fileno(fp));
496     fclose(fp); /* done with stdio */
497 gregl 3.29 for (n = 0; nextloc > 0L; n++) { /* initialize each section */
498     lseek(fd, (long)nextloc, 0);
499     read(fd, (char *)&nextloc, sizeof(nextloc));
500     hdinit(fd, NULL);
501     }
502     if (n != vdef(SECTION)) {
503     sprintf(errmsg, "number of sections does not match %s setting",
504     vnam(SECTION));
505     error(WARNING, errmsg);
506     }
507 gregl 3.1 }
508    
509    
510     done_packets(pl) /* handle finished packets */
511     PACKET *pl;
512     {
513 gregl 3.13 static int n2flush = 0;
514 gregl 3.1 register PACKET *p;
515    
516     while (pl != NULL) {
517     p = pl; pl = p->next; p->next = NULL;
518     if (p->nr > 0) { /* add to holodeck */
519     bcopy((char *)p->ra,
520     (char *)hdnewrays(hdlist[p->hd],p->bi,p->nr),
521     p->nr*sizeof(RAYVAL));
522     if (outdev != NULL) /* display it */
523 gregl 3.7 disp_packet((PACKHEAD *)p);
524 gwlarson 3.49 if (hdcachesize <= 0)
525 gregl 3.33 n2flush++;
526 gregl 3.6 nraysdone += p->nr;
527     npacksdone++;
528 gregl 3.33 p->nr = 0;
529 gregl 3.1 }
530 gregl 3.33 p->next = freepacks; /* push onto free list */
531 gregl 3.1 freepacks = p;
532 gregl 3.5 }
533 gwlarson 3.50 if (n2flush >= RTFLUSH) {
534 gwlarson 3.46 if (outdev != NULL)
535     hdsync(NULL, 1);
536 gwlarson 3.41 else
537 gwlarson 3.46 hdflush(NULL);
538 gregl 3.13 n2flush = 0;
539 gregl 3.1 }
540     }
541    
542    
543     rootname(rn, fn) /* remove tail from end of fn */
544     register char *rn, *fn;
545     {
546     char *tp, *dp;
547    
548     for (tp = NULL, dp = rn; *rn = *fn++; rn++)
549 gregl 3.22 if (*rn == '/')
550 gregl 3.1 dp = rn;
551     else if (*rn == '.')
552     tp = rn;
553     if (tp != NULL && tp > dp)
554     *tp = '\0';
555     }
556    
557    
558     badvalue(vc) /* report bad variable value and exit */
559     int vc;
560     {
561     sprintf(errmsg, "bad value for variable '%s'", vnam(vc));
562     error(USER, errmsg);
563     }
564    
565    
566     eputs(s) /* put error message to stderr */
567     register char *s;
568     {
569     static int midline = 0;
570    
571     if (!*s)
572     return;
573     if (!midline++) { /* prepend line with program name */
574     fputs(progname, stderr);
575     fputs(": ", stderr);
576     }
577     fputs(s, stderr);
578     if (s[strlen(s)-1] == '\n') {
579     fflush(stderr);
580     midline = 0;
581     }
582     }
583    
584    
585     quit(ec) /* exit program gracefully */
586     int ec;
587     {
588     int status = 0;
589    
590 gregl 3.24 if (hdlist[0] != NULL) { /* close holodeck */
591 gregl 3.21 if (nprocs > 0)
592 gregl 3.24 status = done_rtrace(); /* calls hdsync() */
593 gregl 3.19 if (ncprocs > 0 && vdef(REPORT)) {
594     long fsiz, fuse;
595     fsiz = hdfilen(hdlist[0]->fd);
596     fuse = hdfiluse(hdlist[0]->fd, 1);
597     fprintf(stderr,
598 gregl 3.3 "%s: %.1f Mbyte holodeck file, %.1f%% fragmentation\n",
599 gregl 3.19 hdkfile, fsiz/(1024.*1024.),
600     100.*(fsiz-fuse)/fsiz);
601     }
602 gregl 3.1 }
603 gregl 3.12 if (orig_mode >= 0) /* reset holodeck access mode */
604     fchmod(hdlist[0]->fd, orig_mode);
605 gregl 3.11 if (outdev != NULL) /* close display */
606     disp_close();
607 gregl 3.1 exit(ec ? ec : status); /* exit */
608     }