ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rholo.c
Revision: 3.47
Committed: Wed Jan 20 13:28:49 1999 UTC (25 years, 3 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 3.46: +6 -4 lines
Log Message:
added hdsync() call prior to double-signal exit

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 gwlarson 3.47 if (gotsig > 1) /* we're going as fast as we can! */
154     return;
155     if (gotsig++) { /* two signals and we split */
156     hdsync(NULL, 0); /* don't leave w/o saying goodbye */
157 gregl 3.12 _exit(signo);
158 gwlarson 3.47 }
159     alarm(300); /* allow 5 minutes to clean up */
160 gregl 3.12 eputs("signal - ");
161     eputs(sigerr[signo]);
162     eputs("\n");
163     quit(3);
164     }
165    
166    
167     sigdie(signo, msg) /* set fatal signal */
168     int signo;
169     char *msg;
170     {
171     if (signal(signo, onsig) == SIG_IGN)
172     signal(signo, SIG_IGN);
173     sigerr[signo] = msg;
174     }
175    
176    
177     int
178     resfmode(fd, mod) /* restrict open file access mode */
179     int fd, mod;
180     {
181     struct stat stbuf;
182     /* get original mode */
183     if (fstat(fd, &stbuf) < 0)
184     error(SYSTEM, "cannot stat open holodeck file");
185     mod &= stbuf.st_mode; /* always more restrictive */
186 gregl 3.35 if (mod == (stbuf.st_mode & 0777))
187 gregl 3.12 return(-1); /* already set */
188     /* else change it */
189     if (fchmod(fd, mod) < 0) {
190     error(WARNING, "cannot change holodeck file access mode");
191     return(-1);
192     }
193     return(stbuf.st_mode); /* return original mode */
194     }
195    
196    
197 gregl 3.1 initrholo() /* get our holodeck running */
198     {
199     extern int global_packet();
200     register int i;
201 gregl 3.17 /* close holodeck on exec() */
202     fcntl(hdlist[0]->fd, F_SETFD, FD_CLOEXEC);
203 gregl 3.4
204     if (outdev != NULL) /* open output device */
205     disp_open(outdev);
206 gregl 3.1 else if (ncprocs > 0) /* else use global ray feed */
207     init_global();
208 gregl 3.8 /* record disk space limit */
209     if (!vdef(DISKSPACE))
210     maxdisk = 0;
211     else
212 gregl 3.9 maxdisk = 1024.*1024.*vflt(DISKSPACE);
213 gregl 3.1 /* set up memory cache */
214 gregl 3.5 if (outdev == NULL)
215     hdcachesize = 0; /* manual flushing */
216     else if (vdef(CACHE))
217     hdcachesize = 1024.*1024.*vflt(CACHE);
218 gregl 3.1 /* open report file */
219     if (vdef(REPORT)) {
220     register char *s = sskip2(vval(REPORT), 1);
221     if (*s && freopen(s, "a", stderr) == NULL)
222     quit(2);
223     }
224 gregl 3.33 /* mark the starting time */
225     starttime = time(NULL);
226     /* compute end time */
227     if (!vdef(TIME) || vflt(TIME) <= FTINY)
228     endtime = 0;
229     else
230     endtime = starttime + vflt(TIME)*3600. + .5;
231 gregl 3.1 /* start rtrace */
232     if (ncprocs > 0) {
233 gwlarson 3.38 totqlen = i = start_rtrace();
234 gregl 3.1 if (i < 1)
235 gregl 3.20 error(USER, "cannot start rtrace process(es)");
236 gregl 3.1 if (vdef(REPORT)) { /* make first report */
237     printargs(rtargc, rtargv, stderr);
238     report(0);
239     }
240     /* allocate packets */
241     freepacks = (PACKET *)bmalloc(i*sizeof(PACKET));
242     if (freepacks == NULL)
243     goto memerr;
244     freepacks[--i].nr = 0;
245     freepacks[i].next = NULL;
246 gregl 3.25 if (!vdef(OBSTRUCTIONS) || !vbool(OBSTRUCTIONS)) {
247 gregl 3.1 freepacks[i].offset = (float *)bmalloc(
248     RPACKSIZ*sizeof(float)*(i+1) );
249     if (freepacks[i].offset == NULL)
250     goto memerr;
251     } else
252     freepacks[i].offset = NULL;
253     while (i--) {
254     freepacks[i].nr = 0;
255     freepacks[i].offset = freepacks[i+1].offset == NULL ?
256     NULL : freepacks[i+1].offset+RPACKSIZ ;
257     freepacks[i].next = &freepacks[i+1];
258     }
259     }
260 gregl 3.12 /* set up signal handling */
261     sigdie(SIGINT, "Interrupt");
262     sigdie(SIGHUP, "Hangup");
263     sigdie(SIGTERM, "Terminate");
264     sigdie(SIGPIPE, "Broken pipe");
265     sigdie(SIGALRM, "Alarm clock");
266     #ifdef SIGXCPU
267     sigdie(SIGXCPU, "CPU limit exceeded");
268     sigdie(SIGXFSZ, "File size exceeded");
269     #endif
270     /* protect holodeck file */
271     orig_mode = resfmode(hdlist[0]->fd, ncprocs>0 ? 0 : 0444);
272 gregl 3.1 return;
273     memerr:
274     error(SYSTEM, "out of memory in initrholo");
275     }
276    
277    
278     rholo() /* holodeck main loop */
279     {
280 gwlarson 3.44 static long nextfragwarn = 100*(1L<<20);
281 gregl 3.30 static int idle = 0;
282 gregl 3.1 PACKET *pl = NULL, *plend;
283 gwlarson 3.44 long fsiz;
284 gregl 3.33 int pksiz;
285 gregl 3.1 register PACKET *p;
286     time_t t;
287 gregl 3.30 /* check display */
288     if (nprocs <= 0)
289     idle = 1;
290     if (outdev != NULL) {
291 gregl 3.4 if (!disp_check(idle))
292 gregl 3.30 return(0); /* quit request */
293     if (nprocs <= 0)
294     return(1);
295     } else if (idle)
296     return(0); /* all done */
297 gwlarson 3.44 fsiz = hdfilen(hdlist[0]->fd); /* check file size */
298     if (maxdisk > 0 && fsiz >= maxdisk) {
299 gregl 3.8 error(WARNING, "file limit exceeded");
300 gregl 3.21 done_rtrace();
301     return(1); /* comes back */
302 gregl 3.8 }
303 gwlarson 3.44 #if FRAGWARN
304     if (fsiz >= nextfragwarn &&
305     (fsiz-hdfiluse(hdlist[0]->fd,0))/(fsiz/100) > FRAGWARN) {
306     sprintf(errmsg, "holodeck file fragmentation is %.0f%%",
307     100.*(fsiz-hdfiluse(hdlist[0]->fd,1))/fsiz);
308     error(WARNING, errmsg);
309     nextfragwarn = fsiz + (fsiz>>2); /* decent interval */
310     }
311     #endif
312 gregl 3.33 t = time(NULL); /* check time */
313 gregl 3.8 if (endtime > 0 && t >= endtime) {
314     error(WARNING, "time limit exceeded");
315 gregl 3.21 done_rtrace();
316     return(1); /* comes back */
317 gregl 3.8 }
318 gregl 3.3 if (reporttime > 0 && t >= reporttime)
319 gregl 3.1 report(t);
320 gregl 3.33 /* figure out good packet size */
321     #if MAXQTIME
322 gwlarson 3.38 pksiz = nraysdone*MAXQTIME/(totqlen*(t - starttime + 1L));
323 gregl 3.33 if (pksiz < 1)
324     pksiz = 1;
325     else if (pksiz > RPACKSIZ)
326     #endif
327     pksiz = RPACKSIZ;
328 gregl 3.28 idle = 0; /* get packets to process */
329 gregl 3.1 while (freepacks != NULL) {
330     p = freepacks; freepacks = p->next; p->next = NULL;
331 gregl 3.33 if (!next_packet(p, pksiz)) {
332 gregl 3.1 p->next = freepacks; freepacks = p;
333 gregl 3.21 idle = 1;
334 gregl 3.1 break;
335     }
336     if (pl == NULL) pl = p;
337     else plend->next = p;
338     plend = p;
339     }
340 gregl 3.21 /* process packets */
341 gregl 3.1 done_packets(do_packets(pl));
342     return(1); /* and continue */
343     }
344    
345    
346     setdefaults(gp) /* set default values */
347     register HDGRID *gp;
348     {
349     extern char *atos();
350     register int i;
351 gregl 3.29 int n;
352 gregl 3.37 double len[3], d;
353 gregl 3.1 char buf[64];
354    
355     if (!vdef(SECTION)) {
356     sprintf(errmsg, "%s must be defined", vnam(SECTION));
357     error(USER, errmsg);
358     }
359     if (!vdef(OCTREE)) {
360     if ((vval(OCTREE) = bmalloc(strlen(froot)+5)) == NULL)
361     error(SYSTEM, "out of memory");
362     sprintf(vval(OCTREE), "%s.oct", froot);
363     vdef(OCTREE)++;
364 gregl 3.14 }
365     if (!vdef(VDIST)) {
366     vval(VDIST) = "F";
367     vdef(VDIST)++;
368 gregl 3.1 }
369     /* append rendering options */
370     if (vdef(RENDER))
371     rtargc += wordstring(rtargv+rtargc, vval(RENDER));
372 gregl 3.15
373     if (gp == NULL) /* already initialized? */
374     return;
375     /* set grid parameters */
376 gregl 3.29 for (n = 0; n < vdef(SECTION); n++, gp++) {
377     gp->grid[0] = gp->grid[1] = gp->grid[2] = 0;
378     if (sscanf(nvalue(SECTION, n),
379 gregl 3.16 "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %hd %hd %hd",
380 gregl 3.29 &gp->orig[0], &gp->orig[1], &gp->orig[2],
381     &gp->xv[0][0], &gp->xv[0][1], &gp->xv[0][2],
382     &gp->xv[1][0], &gp->xv[1][1], &gp->xv[1][2],
383     &gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2],
384     &gp->grid[0], &gp->grid[1], &gp->grid[2]) < 12)
385     badvalue(SECTION);
386     for (i = 0; i < 3; i++)
387 gregl 3.37 len[i] = VLEN(gp->xv[i]);
388     if (!vdef(GRID)) {
389 gwlarson 3.43 d = 2/2e5*( len[0]*len[0]*(len[1]*len[1] +
390 gregl 3.37 len[2]*len[2] + 4*len[1]*len[2])
391     + len[1]*len[1]*len[2]*(len[2] + 4*len[0])
392     + 4*len[0]*len[1]*len[2]*len[2] );
393     d = sqrt(sqrt(d));
394     } else if ((d = vflt(GRID)) <= FTINY)
395 gregl 3.29 badvalue(GRID);
396     for (i = 0; i < 3; i++)
397     if (gp->grid[i] <= 0)
398     gp->grid[i] = len[i]/d + (1.-FTINY);
399 gregl 3.15 }
400 gregl 3.1 }
401    
402    
403     creatholo(gp) /* create a holodeck output file */
404     HDGRID *gp;
405     {
406 gregl 3.12 extern char VersionID[];
407 gregl 3.29 int4 lastloc, nextloc;
408     int n;
409 gregl 3.10 int fd;
410 gregl 3.1 FILE *fp;
411     /* open & truncate file */
412     if ((fp = fopen(hdkfile, "w+")) == NULL) {
413     sprintf(errmsg, "cannot open \"%s\" for writing", hdkfile);
414     error(SYSTEM, errmsg);
415     }
416     /* write information header */
417     newheader("RADIANCE", fp);
418 gregl 3.12 fprintf(fp, "SOFTWARE= %s\n", VersionID);
419 gregl 3.1 printvars(fp);
420     fputformat(HOLOFMT, fp);
421     fputc('\n', fp);
422 gregl 3.29 putw(HOLOMAGIC, fp); /* put magic number */
423 gregl 3.10 fd = dup(fileno(fp));
424     fclose(fp); /* flush and close stdio stream */
425 gregl 3.29 lastloc = lseek(fd, 0L, 2);
426     for (n = vdef(SECTION); n--; gp++) { /* initialize each section */
427     nextloc = 0L;
428     write(fd, (char *)&nextloc, sizeof(nextloc));
429     hdinit(fd, gp); /* writes beam index */
430     if (!n)
431     break;
432     nextloc = hdfilen(fd); /* write section pointer */
433     if (lseek(fd, (long)lastloc, 0) < 0)
434     error(SYSTEM,
435     "cannot seek on holodeck file in creatholo");
436     write(fd, (char *)&nextloc, sizeof(nextloc));
437     lseek(fd, (long)(lastloc=nextloc), 0);
438     }
439 gregl 3.1 }
440    
441    
442 gwlarson 3.42 int
443 gregl 3.1 headline(s) /* process information header line */
444     char *s;
445     {
446     extern char FMTSTR[];
447     register char *cp;
448     char fmt[32];
449    
450 gregl 3.2 if (formatval(fmt, s)) {
451 gregl 3.1 if (strcmp(fmt, HOLOFMT)) {
452     sprintf(errmsg, "%s file \"%s\" has %s%s",
453     HOLOFMT, hdkfile, FMTSTR, fmt);
454     error(USER, errmsg);
455     }
456 gwlarson 3.42 return(0);
457 gregl 3.1 }
458     for (cp = s; *cp; cp++) /* take off any comments */
459     if (*cp == '#') {
460     *cp = '\0';
461     break;
462     }
463     setvariable(s, matchvar); /* don't flag errors */
464 gwlarson 3.42 return(0);
465 gregl 3.1 }
466    
467    
468     loadholo() /* start loading a holodeck from fname */
469     {
470 gregl 3.10 extern long ftell();
471 gregl 3.1 FILE *fp;
472 gregl 3.10 int fd;
473 gregl 3.29 int n;
474     int4 nextloc;
475 gregl 3.4 /* open holodeck file */
476     if ((fp = fopen(hdkfile, ncprocs>0 ? "r+" : "r")) == NULL) {
477 gwlarson 3.39 sprintf(errmsg, "cannot %s \"%s\"",
478     ncprocs>0 ? "append" : "read", hdkfile);
479 gregl 3.1 error(SYSTEM, errmsg);
480     }
481     /* load variables from header */
482     getheader(fp, headline, NULL);
483     /* check magic number */
484     if (getw(fp) != HOLOMAGIC) {
485     sprintf(errmsg, "bad magic number in holodeck file \"%s\"",
486     hdkfile);
487     error(USER, errmsg);
488     }
489 gregl 3.29 nextloc = ftell(fp); /* get stdio position */
490 gregl 3.10 fd = dup(fileno(fp));
491     fclose(fp); /* done with stdio */
492 gregl 3.29 for (n = 0; nextloc > 0L; n++) { /* initialize each section */
493     lseek(fd, (long)nextloc, 0);
494     read(fd, (char *)&nextloc, sizeof(nextloc));
495     hdinit(fd, NULL);
496     }
497     if (n != vdef(SECTION)) {
498     sprintf(errmsg, "number of sections does not match %s setting",
499     vnam(SECTION));
500     error(WARNING, errmsg);
501     }
502 gregl 3.1 }
503    
504    
505     done_packets(pl) /* handle finished packets */
506     PACKET *pl;
507     {
508 gregl 3.13 static int n2flush = 0;
509 gregl 3.1 register PACKET *p;
510    
511     while (pl != NULL) {
512     p = pl; pl = p->next; p->next = NULL;
513     if (p->nr > 0) { /* add to holodeck */
514     bcopy((char *)p->ra,
515     (char *)hdnewrays(hdlist[p->hd],p->bi,p->nr),
516     p->nr*sizeof(RAYVAL));
517     if (outdev != NULL) /* display it */
518 gregl 3.7 disp_packet((PACKHEAD *)p);
519 gwlarson 3.46 if (hdcachesize <= 0) {
520     #if RTFLUSH
521     if (outdev == NULL)
522     hdfreebeam(hdlist[p->hd], p->bi);
523     #endif
524 gregl 3.33 n2flush++;
525 gwlarson 3.46 }
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.41 #if MAXQTIME
534 gwlarson 3.38 if (n2flush > 300/MAXQTIME*totqlen) {
535 gwlarson 3.41 #else
536     if (n2flush > 50*totqlen) {
537     #endif
538 gwlarson 3.46 #if RTFLUSH
539     hdsync(NULL, outdev!=NULL); /* sync beams & directories */
540     #else
541     if (outdev != NULL)
542     hdsync(NULL, 1);
543 gwlarson 3.41 else
544 gwlarson 3.46 hdflush(NULL);
545     #endif
546 gregl 3.13 n2flush = 0;
547 gregl 3.1 }
548     }
549    
550    
551     rootname(rn, fn) /* remove tail from end of fn */
552     register char *rn, *fn;
553     {
554     char *tp, *dp;
555    
556     for (tp = NULL, dp = rn; *rn = *fn++; rn++)
557 gregl 3.22 if (*rn == '/')
558 gregl 3.1 dp = rn;
559     else if (*rn == '.')
560     tp = rn;
561     if (tp != NULL && tp > dp)
562     *tp = '\0';
563     }
564    
565    
566     badvalue(vc) /* report bad variable value and exit */
567     int vc;
568     {
569     sprintf(errmsg, "bad value for variable '%s'", vnam(vc));
570     error(USER, errmsg);
571     }
572    
573    
574     eputs(s) /* put error message to stderr */
575     register char *s;
576     {
577     static int midline = 0;
578    
579     if (!*s)
580     return;
581     if (!midline++) { /* prepend line with program name */
582     fputs(progname, stderr);
583     fputs(": ", stderr);
584     }
585     fputs(s, stderr);
586     if (s[strlen(s)-1] == '\n') {
587     fflush(stderr);
588     midline = 0;
589     }
590     }
591    
592    
593     quit(ec) /* exit program gracefully */
594     int ec;
595     {
596     int status = 0;
597    
598 gregl 3.24 if (hdlist[0] != NULL) { /* close holodeck */
599 gregl 3.21 if (nprocs > 0)
600 gregl 3.24 status = done_rtrace(); /* calls hdsync() */
601 gregl 3.19 if (ncprocs > 0 && vdef(REPORT)) {
602     long fsiz, fuse;
603     fsiz = hdfilen(hdlist[0]->fd);
604     fuse = hdfiluse(hdlist[0]->fd, 1);
605     fprintf(stderr,
606 gregl 3.3 "%s: %.1f Mbyte holodeck file, %.1f%% fragmentation\n",
607 gregl 3.19 hdkfile, fsiz/(1024.*1024.),
608     100.*(fsiz-fuse)/fsiz);
609     }
610 gregl 3.1 }
611 gregl 3.12 if (orig_mode >= 0) /* reset holodeck access mode */
612     fchmod(hdlist[0]->fd, orig_mode);
613 gregl 3.11 if (outdev != NULL) /* close display */
614     disp_close();
615 gregl 3.1 exit(ec ? ec : status); /* exit */
616     }