ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rholo.c
(Generate patch)

Comparing ray/src/hd/rholo.c (file contents):
Revision 3.2 by gregl, Fri Oct 31 11:44:09 1997 UTC vs.
Revision 3.27 by gregl, Sun Dec 14 09:46:52 1997 UTC

# Line 9 | Line 9 | static char SCCSid[] = "$SunId$ SGI";
9   */
10  
11   #include "rholo.h"
12 < #include "paths.h"
12 > #include "random.h"
13 > #include <signal.h>
14   #include <sys/types.h>
15 + #include <sys/stat.h>
16  
17                          /* the following must be consistent with rholo.h */
18   int     NVARS = NRHVARS;                /* total number of variables */
# Line 19 | Line 21 | VARIABLE       vv[] = RHVINIT;         /* variable-value pairs */
21  
22   char    *progname;              /* our program name */
23   char    *hdkfile;               /* holodeck file name */
24 < char    froot[MAXPATH];         /* root file name */
24 > char    froot[256];             /* root file name */
25  
26   int     nowarn = 0;             /* turn warnings off? */
27  
26 double  expval = 1.;            /* global exposure value */
27
28   int     ncprocs = 0;            /* desired number of compute processes */
29  
30   char    *outdev = NULL;         /* output device name */
31  
32 + int     readinp = 0;            /* read commands from stdin */
33 +
34 + int     force = 0;              /* allow overwrite of holodeck */
35 +
36   time_t  starttime;              /* time we got started */
37   time_t  endtime;                /* time we should end by */
38   time_t  reporttime;             /* time for next report */
39  
40 + long    maxdisk;                /* maximum file space (bytes) */
41 +
42   int     rtargc = 1;             /* rtrace command */
43   char    *rtargv[128] = {"rtrace", NULL};
44  
45 + int     orig_mode = -1;         /* original file mode (-1 if unchanged) */
46 +
47   long    nraysdone = 0L;         /* number of rays done */
48   long    npacksdone = 0L;        /* number of packets done */
49  
50   PACKET  *freepacks;             /* available packets */
51  
52 + char  *sigerr[NSIG];            /* signal error messages */
53 +
54   extern time_t   time();
55  
56  
# Line 50 | Line 60 | char   *argv[];
60   {
61          HDGRID  hdg;
62          int     i;
63 <        int     force = 0;
64 <
63 >                                                /* mark start time */
64 >        starttime = time(NULL);
65 >        initurand(16384);                       /* initialize urand */
66          progname = argv[0];                     /* get arguments */
67          for (i = 1; i < argc && argv[i][0] == '-'; i++)
68                  switch (argv[i][1]) {
# Line 61 | Line 72 | char   *argv[];
72                  case 'f':                       /* force overwrite */
73                          force++;
74                          break;
75 +                case 'i':                       /* read input from stdin */
76 +                        readinp++;
77 +                        break;
78                  case 'n':                       /* compute processes */
79                          if (i >= argc-2)
80                                  goto userr;
# Line 74 | Line 88 | char   *argv[];
88                  default:
89                          goto userr;
90                  }
77                                                /* do we have a job? */
78        if (outdev == NULL && ncprocs <= 0)
79                goto userr;
91                                                  /* get root file name */
92          rootname(froot, hdkfile=argv[i++]);
93 <                                                /* load... */
94 <        if (i < argc) {                         /* variables */
95 <                loadvars(argv[i++]);
96 <                                                        /* cmdline settings */
97 <                for ( ; i < argc; i++)
98 <                        if (setvariable(argv[i], matchvar) < 0) {
99 <                                sprintf(errmsg, "unknown variable: %s",
100 <                                                argv[i]);
101 <                                error(USER, errmsg);
102 <                        }
103 <                                                        /* check settings */
104 <                checkvalues();
105 <                                                        /* load RIF if any */
106 <                if (vdef(RIF))
107 <                        getradfile(vval(RIF));
93 >                                                /* load variables? */
94 >        if (i < argc)
95 >                if (argv[i][0] != '-' && argv[i][0] != '+')
96 >                        loadvars(argv[i]);      /* load variables from file */
97 >
98 >        if (i >= argc || argv[i][0] == '+')
99 >                loadholo();                     /* load existing holodeck */
100 >
101 >        while (++i < argc)                      /* get command line settings */
102 >                if (setvariable(argv[i], matchvar) < 0) {
103 >                        sprintf(errmsg, "unknown variable: %s", argv[i]);
104 >                        error(USER, errmsg);
105 >                }
106 >                                                /* check settings */
107 >        checkvalues();
108 >                                                /* load RIF if any */
109 >        getradfile();
110 >
111 >        if (hdlist[i] == NULL) {                /* create new holodeck */
112                                                          /* set defaults */
113                  setdefaults(&hdg);
114                                                          /* holodeck exists? */
# Line 102 | Line 117 | char   *argv[];
117                                  "holodeck file exists -- use -f to overwrite");
118                                                          /* create holodeck */
119                  creatholo(&hdg);
120 <        } else                                  /* else load holodeck */
121 <                loadholo();
120 >        } else                                  /* else just set defaults */
121 >                setdefaults(NULL);
122                                                  /* initialize */
123          initrholo();
124 <                                                /* run */
124 >                                                /* main loop */
125          while (rholo())
126                  ;
127                                                  /* done */
128          quit(0);
129   userr:
130          fprintf(stderr,
131 < "Usage: %s {-n nprocs|-o disp} [-w][-f] output.hdk [control.hif [VAR=val ..]]\n",
131 > "Usage: %s [-n nprocs][-o disp][-w][-f] output.hdk [control.hif|+|- [VAR=val ..]]\n",
132                          progname);
133          quit(1);
134   }
135  
136  
137 + onsig(signo)                            /* fatal signal */
138 + int  signo;
139 + {
140 +        static int  gotsig = 0;
141 +
142 +        if (gotsig++)                   /* two signals and we're gone! */
143 +                _exit(signo);
144 +
145 +        alarm(30);                      /* allow 30 seconds to clean up */
146 +        signal(SIGALRM, SIG_DFL);       /* make certain we do die */
147 +        eputs("signal - ");
148 +        eputs(sigerr[signo]);
149 +        eputs("\n");
150 +        quit(3);
151 + }
152 +
153 +
154 + sigdie(signo, msg)                      /* set fatal signal */
155 + int  signo;
156 + char  *msg;
157 + {
158 +        if (signal(signo, onsig) == SIG_IGN)
159 +                signal(signo, SIG_IGN);
160 +        sigerr[signo] = msg;
161 + }
162 +
163 +
164 + int
165 + resfmode(fd, mod)               /* restrict open file access mode */
166 + int     fd, mod;
167 + {
168 +        struct stat     stbuf;
169 +                                        /* get original mode */
170 +        if (fstat(fd, &stbuf) < 0)
171 +                error(SYSTEM, "cannot stat open holodeck file");
172 +        mod &= stbuf.st_mode;           /* always more restrictive */
173 +        if (mod == stbuf.st_mode)
174 +                return(-1);             /* already set */
175 +                                        /* else change it */
176 +        if (fchmod(fd, mod) < 0) {
177 +                error(WARNING, "cannot change holodeck file access mode");
178 +                return(-1);
179 +        }
180 +        return(stbuf.st_mode);          /* return original mode */
181 + }
182 +
183 +
184   initrholo()                     /* get our holodeck running */
185   {
186          extern int      global_packet();
187          register int    i;
188 <                                                /* check output device */
189 <        if (outdev != NULL)
190 <                open_display(outdev);
188 >                                                /* close holodeck on exec() */
189 >        fcntl(hdlist[0]->fd, F_SETFD, FD_CLOEXEC);
190 >
191 >        if (outdev != NULL)                     /* open output device */
192 >                disp_open(outdev);
193          else if (ncprocs > 0)                   /* else use global ray feed */
194                  init_global();
195 <                                                /* record the time */
196 <        starttime = time(NULL);
195 >                                                /* record disk space limit */
196 >        if (!vdef(DISKSPACE))
197 >                maxdisk = 0;
198 >        else
199 >                maxdisk = 1024.*1024.*vflt(DISKSPACE);
200 >                                                /* record end time */
201          if (!vdef(TIME) || vflt(TIME) <= FTINY)
202                  endtime = 0;
203          else
204 <                endtime = starttime + vflt(TIME)*3600.;
204 >                endtime = starttime + vflt(TIME)*3600. + .5;
205                                                  /* set up memory cache */
206 <        hdcachesize = 1024.*1024.*vflt(CACHE);
206 >        if (outdev == NULL)
207 >                hdcachesize = 0;        /* manual flushing */
208 >        else if (vdef(CACHE))
209 >                hdcachesize = 1024.*1024.*vflt(CACHE);
210                                                  /* open report file */
211          if (vdef(REPORT)) {
212                  register char   *s = sskip2(vval(REPORT), 1);
# Line 146 | Line 217 | initrholo()                    /* get our holodeck running */
217          if (ncprocs > 0) {
218                  i = start_rtrace();
219                  if (i < 1)
220 <                        error(USER, "cannot start rtrace process");
220 >                        error(USER, "cannot start rtrace process(es)");
221                  if (vdef(REPORT)) {             /* make first report */
222                          printargs(rtargc, rtargv, stderr);
223                          report(0);
# Line 157 | Line 228 | initrholo()                    /* get our holodeck running */
228                          goto memerr;
229                  freepacks[--i].nr = 0;
230                  freepacks[i].next = NULL;
231 <                if (!vbool(OBSTRUCTIONS)) {
231 >                if (!vdef(OBSTRUCTIONS) || !vbool(OBSTRUCTIONS)) {
232                          freepacks[i].offset = (float *)bmalloc(
233                                          RPACKSIZ*sizeof(float)*(i+1) );
234                          if (freepacks[i].offset == NULL)
# Line 171 | Line 242 | initrholo()                    /* get our holodeck running */
242                          freepacks[i].next = &freepacks[i+1];
243                  }
244          }
245 +                                        /* set up signal handling */
246 +        sigdie(SIGINT, "Interrupt");
247 +        sigdie(SIGHUP, "Hangup");
248 +        sigdie(SIGTERM, "Terminate");
249 +        sigdie(SIGPIPE, "Broken pipe");
250 +        sigdie(SIGALRM, "Alarm clock");
251 + #ifdef  SIGXCPU
252 +        sigdie(SIGXCPU, "CPU limit exceeded");
253 +        sigdie(SIGXFSZ, "File size exceeded");
254 + #endif
255 +                                                /* protect holodeck file */
256 +        orig_mode = resfmode(hdlist[0]->fd, ncprocs>0 ? 0 : 0444);
257          return;
258   memerr:
259          error(SYSTEM, "out of memory in initrholo");
# Line 184 | Line 267 | rholo()                                /* holodeck main loop */
267          register PACKET *p;
268          time_t  t;
269          long    l;
270 <                                        /* check display */
271 <        if (outdev != NULL && !disp_check(idle))
272 <                return(0);
270 >
271 >        if (outdev != NULL)             /* check display */
272 >                if (!disp_check(idle))
273 >                        return(0);
274                                          /* display only? */
275 <        if (ncprocs <= 0)
276 <                return(1);
275 >        if (nprocs <= 0)
276 >                return(outdev != NULL);
277                                          /* check file size */
278 <        if ((l = 1024.*1024.*vflt(DISKSPACE)) > 0 &&
279 <                        hdfiluse(hdlist[0]->fd, 0) + hdmemuse(0) >= l)
280 <                return(0);
278 >        if (maxdisk > 0 && hdfilen(hdlist[0]->fd) >= maxdisk) {
279 >                error(WARNING, "file limit exceeded");
280 >                done_rtrace();
281 >                idle = 1;
282 >                return(1);      /* comes back */
283 >        }
284                                          /* check time */
285 <        if (endtime > 0 || vdef(REPORT))
285 >        if (endtime > 0 || reporttime > 0)
286                  t = time(NULL);
287 <        if (endtime > 0 && t >= endtime)
288 <                return(0);
289 <        if (vdef(REPORT) && t >= reporttime)
287 >        if (endtime > 0 && t >= endtime) {
288 >                error(WARNING, "time limit exceeded");
289 >                done_rtrace();
290 >                idle = 1;
291 >                return(1);      /* comes back */
292 >        }
293 >        if (reporttime > 0 && t >= reporttime)
294                  report(t);
295                                          /* get packets to process */
296          while (freepacks != NULL) {
297                  p = freepacks; freepacks = p->next; p->next = NULL;
298                  if (!next_packet(p)) {
299                          p->next = freepacks; freepacks = p;
300 +                        idle = 1;
301                          break;
302                  }
303                  if (pl == NULL) pl = p;
304                  else plend->next = p;
305                  plend = p;
306          }
307 <        idle = pl == NULL && freepacks != NULL;
216 <                                        /* are we out of stuff to do? */
217 <        if (idle && outdev == NULL)
218 <                return(0);
219 <                                        /* else process packets */
307 >                                        /* process packets */
308          done_packets(do_packets(pl));
309          return(1);                      /* and continue */
310   }
311  
312  
225 report(t)                       /* report progress so far */
226 time_t  t;
227 {
228        if (t == 0)
229                t = time(NULL);
230        fprintf(stderr, "%s: %ld packets (%ld rays) done after %.2f hours\n",
231                        progname, npacksdone, nraysdone, (t-starttime)/3600.);
232        fflush(stderr);
233        reporttime = t + (time_t)(vflt(REPORT)*60.);
234 }
235
236
313   setdefaults(gp)                 /* set default values */
314   register HDGRID *gp;
315   {
# Line 250 | Line 326 | register HDGRID        *gp;
326                  sprintf(errmsg, "ignoring all but first %s", vnam(SECTION));
327                  error(WARNING, errmsg);
328          }
329 +        if (!vdef(OCTREE)) {
330 +                if ((vval(OCTREE) = bmalloc(strlen(froot)+5)) == NULL)
331 +                        error(SYSTEM, "out of memory");
332 +                sprintf(vval(OCTREE), "%s.oct", froot);
333 +                vdef(OCTREE)++;
334 +        }
335 +        if (!vdef(VDIST)) {
336 +                vval(VDIST) = "F";
337 +                vdef(VDIST)++;
338 +        }
339 +        if (!vdef(OCCUPANCY)) {
340 +                vval(OCCUPANCY) = "U";
341 +                vdef(OCCUPANCY)++;
342 +        }
343 +                                /* append rendering options */
344 +        if (vdef(RENDER))
345 +                rtargc += wordstring(rtargv+rtargc, vval(RENDER));
346 +        
347 +        if (gp == NULL)         /* already initialized? */
348 +                return;
349 +                                /* set grid parameters */
350 +        gp->grid[0] = gp->grid[1] = gp->grid[2] = 0;
351          if (sscanf(vval(SECTION),
352 <                        "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",
352 >                "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %hd %hd %hd",
353                          &gp->orig[0], &gp->orig[1], &gp->orig[2],
354                          &gp->xv[0][0], &gp->xv[0][1], &gp->xv[0][2],
355                          &gp->xv[1][0], &gp->xv[1][1], &gp->xv[1][2],
356 <                        &gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2]) != 12)
356 >                        &gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2],
357 >                        &gp->grid[0], &gp->grid[1], &gp->grid[2]) < 12)
358                  badvalue(SECTION);
359          maxlen = 0.;
360          for (i = 0; i < 3; i++)
# Line 269 | Line 368 | register HDGRID        *gp;
368          if ((d = vflt(GRID)) <= FTINY)
369                  badvalue(GRID);
370          for (i = 0; i < 3; i++)
371 <                gp->grid[i] = len[i]/d + (1.-FTINY);
372 <        if (!vdef(EXPOSURE)) {
274 <                sprintf(errmsg, "%s must be defined", vnam(EXPOSURE));
275 <                error(USER, errmsg);
276 <        }
277 <        expval = vval(EXPOSURE)[0] == '-' || vval(EXPOSURE)[0] == '+' ?
278 <                        pow(2., vflt(EXPOSURE)) : vflt(EXPOSURE);
279 <        if (!vdef(OCTREE)) {
280 <                if ((vval(OCTREE) = bmalloc(strlen(froot)+5)) == NULL)
281 <                        error(SYSTEM, "out of memory");
282 <                sprintf(vval(OCTREE), "%s.oct", froot);
283 <                vdef(OCTREE)++;
284 <        }
285 <        if (!vdef(DISKSPACE)) {
286 <                sprintf(errmsg,
287 <                        "no %s setting, assuming 100 Mbytes available",
288 <                                vnam(DISKSPACE));
289 <                error(WARNING, errmsg);
290 <                vval(DISKSPACE) = "100";
291 <                vdef(DISKSPACE)++;
292 <        }
293 <        if (!vdef(CACHE)) {
294 <                sprintf(errmsg,
295 <                        "no %s setting, assuming 10 Mbytes available",
296 <                                vnam(CACHE));
297 <                error(WARNING, errmsg);
298 <                vval(CACHE) = "10";
299 <                vdef(CACHE)++;
300 <        }
301 <        if (!vdef(OBSTRUCTIONS)) {
302 <                vval(OBSTRUCTIONS) = "T";
303 <                vdef(OBSTRUCTIONS)++;
304 <        }
305 <        if (!vdef(OCCUPANCY)) {
306 <                vval(OCCUPANCY) = "U";
307 <                vdef(OCCUPANCY)++;
308 <        }
309 <                                /* append rendering options */
310 <        if (vdef(RENDER))
311 <                rtargc += wordstring(rtargv+rtargc, vval(RENDER));
371 >                if (gp->grid[i] <= 0)
372 >                        gp->grid[i] = len[i]/d + (1.-FTINY);
373   }
374  
375  
376   creatholo(gp)                   /* create a holodeck output file */
377   HDGRID  *gp;
378   {
379 +        extern char     VersionID[];
380          long    endloc = 0;
381 +        int     fd;
382          FILE    *fp;
383                                          /* open & truncate file */
384          if ((fp = fopen(hdkfile, "w+")) == NULL) {
# Line 324 | Line 387 | HDGRID *gp;
387          }
388                                          /* write information header */
389          newheader("RADIANCE", fp);
390 +        fprintf(fp, "SOFTWARE= %s\n", VersionID);
391          printvars(fp);
392          fputformat(HOLOFMT, fp);
393          fputc('\n', fp);
394          putw(HOLOMAGIC, fp);            /* put magic number & terminus */
395          fwrite(&endloc, sizeof(long), 1, fp);
396 <        fflush(fp);                     /* flush buffer */
397 <        hdinit(fileno(fp), gp);         /* allocate and initialize index */
398 <                        /* we're dropping fp here.... */
396 >        fd = dup(fileno(fp));
397 >        fclose(fp);                     /* flush and close stdio stream */
398 >        hdinit(fd, gp);                 /* allocate and initialize index */
399   }
400  
401  
# Line 361 | Line 425 | char   *s;
425  
426   loadholo()                      /* start loading a holodeck from fname */
427   {
428 +        extern long     ftell();
429          FILE    *fp;
430 <        long    endloc;
431 <                                        /* open input file */
432 <        if ((fp = fopen(hdkfile, "r+")) == NULL) {
433 <                sprintf(errmsg, "cannot open \"%s\" for appending", hdkfile);
430 >        int     fd;
431 >        long    fpos;
432 >                                        /* open holodeck file */
433 >        if ((fp = fopen(hdkfile, ncprocs>0 ? "r+" : "r")) == NULL) {
434 >                sprintf(errmsg, "cannot open \"%s\" for %s", hdkfile,
435 >                                ncprocs>0 ? "appending" : "reading");
436                  error(SYSTEM, errmsg);
437          }
438                                          /* load variables from header */
# Line 376 | Line 443 | loadholo()                     /* start loading a holodeck from fname */
443                                  hdkfile);
444                  error(USER, errmsg);
445          }
446 <        fread(&endloc, sizeof(long), 1, fp);
447 <        if (endloc != 0)
446 >        fread(&fpos, sizeof(long), 1, fp);
447 >        if (fpos != 0)
448                  error(WARNING, "ignoring multiple sections in holodeck file");
449 <        fseek(fp, 0L, 1);                       /* align system file pointer */
450 <        hdinit(fileno(fp), NULL);               /* allocate and load index */
451 <                        /* we're dropping fp here.... */
449 >        fpos = ftell(fp);                       /* get stdio position */
450 >        fd = dup(fileno(fp));
451 >        fclose(fp);                             /* done with stdio */
452 >        lseek(fd, fpos, 0);                     /* align system file pointer */
453 >        hdinit(fd, NULL);                       /* allocate and load index */
454   }
455  
456  
457   done_packets(pl)                /* handle finished packets */
458   PACKET  *pl;
459   {
460 +        static int      n2flush = 0;
461          register PACKET *p;
462  
463          while (pl != NULL) {
# Line 397 | Line 467 | PACKET *pl;
467                                  (char *)hdnewrays(hdlist[p->hd],p->bi,p->nr),
468                                  p->nr*sizeof(RAYVAL));
469                          if (outdev != NULL)     /* display it */
470 <                                disp_packet(p);
470 >                                disp_packet((PACKHEAD *)p);
471 >                        if (hdcachesize <= 0)   /* manual flushing */
472 >                                n2flush += p->nr;
473 >                        nraysdone += p->nr;
474 >                        npacksdone++;
475                  }
402                nraysdone += p->nr;
403                npacksdone++;
476                  p->nr = 0;                      /* push onto free list */
477                  p->next = freepacks;
478                  freepacks = p;
479          }
480 < }
481 <
482 <
411 < getradfile(rfargs)              /* run rad and get needed variables */
412 < char    *rfargs;
413 < {
414 <        static short    mvar[] = {VIEW,OCTREE,EXPOSURE,-1};
415 <        static char     tf1[] = TEMPLATE;
416 <        char    tf2[64];
417 <        char    combuf[256];
418 <        register int    i;
419 <        register char   *cp;
420 <                                        /* create rad command */
421 <        mktemp(tf1);
422 <        sprintf(tf2, "%s.rif", tf1);
423 <        sprintf(combuf,
424 <                "rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH",
425 <                        rfargs, tf1);
426 <        cp = combuf;
427 <        while (*cp) cp++;               /* match unset variables */
428 <        for (i = 0; mvar[i] >= 0; i++)
429 <                if (!vdef(mvar[i])) {
430 <                        *cp++ = '|';
431 <                        strcpy(cp, vnam(mvar[i]));
432 <                        while (*cp) cp++;
433 <                }
434 <        sprintf(cp, ")[ \t]*=' > %s", tf2);
435 <        if (system(combuf)) {
436 <                error(SYSTEM, "cannot execute rad command");
437 <                unlink(tf2);                    /* clean up */
438 <                unlink(tf1);
439 <                quit(1);
480 >        if (n2flush > 512*RPACKSIZ*nprocs) {
481 >                hdflush(NULL);                  /* flush holodeck buffers */
482 >                n2flush = 0;
483          }
441        loadvars(tf2);                  /* load variables */
442        rtargc += wordfile(rtargv+rtargc, tf1); /* get rtrace options */
443        unlink(tf2);                    /* clean up */
444        unlink(tf1);
484   }
485  
486  
# Line 451 | Line 490 | register char  *rn, *fn;
490          char    *tp, *dp;
491  
492          for (tp = NULL, dp = rn; *rn = *fn++; rn++)
493 <                if (ISDIRSEP(*rn))
493 >                if (*rn == '/')
494                          dp = rn;
495                  else if (*rn == '.')
496                          tp = rn;
# Line 500 | Line 539 | int    ec;
539   {
540          int     status = 0;
541  
542 <        if (hdlist[0] != NULL) {        /* flush holodeck */
543 <                if (ncprocs > 0) {
544 <                        done_packets(flush_queue());
545 <                        status = end_rtrace();  /* close rtrace */
546 <                        hdflush(NULL);
547 <                        if (vdef(REPORT)) {
548 <                                long    fsiz, fuse;
549 <                                report(0);
550 <                                fsiz = lseek(hdlist[0]->fd, 0L, 2);
551 <                                fuse = hdfiluse(hdlist[0]->fd, 1);
552 <                                fprintf(stderr,
553 <                        "%s: %.1f Mbyte holodeck file, %.2f%% fragmentation\n",
515 <                                                hdkfile, fsiz/(1024.*1024.),
516 <                                                100.*(fsiz-fuse)/fsiz);
517 <                        }
518 <                } else
519 <                        hdflush(NULL);
542 >        if (hdlist[0] != NULL) {        /* close holodeck */
543 >                if (nprocs > 0)
544 >                        status = done_rtrace();         /* calls hdsync() */
545 >                if (ncprocs > 0 && vdef(REPORT)) {
546 >                        long    fsiz, fuse;
547 >                        fsiz = hdfilen(hdlist[0]->fd);
548 >                        fuse = hdfiluse(hdlist[0]->fd, 1);
549 >                        fprintf(stderr,
550 >                        "%s: %.1f Mbyte holodeck file, %.1f%% fragmentation\n",
551 >                                        hdkfile, fsiz/(1024.*1024.),
552 >                                        100.*(fsiz-fuse)/fsiz);
553 >                }
554          }
555 +        if (orig_mode >= 0)             /* reset holodeck access mode */
556 +                fchmod(hdlist[0]->fd, orig_mode);
557 +        if (outdev != NULL)             /* close display */
558 +                disp_close();
559          exit(ec ? ec : status);         /* exit */
560   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines