ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rholo.c
Revision: 3.46
Committed: Thu Jan 7 22:05:34 1999 UTC (25 years, 3 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 3.45: +18 -6 lines
Log Message:
added RTFLUSH define for continuous holodeck flushing (dangerous)

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