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 */ |
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 */ |
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 |
|
|
60 |
|
{ |
61 |
|
HDGRID hdg; |
62 |
|
int i; |
55 |
– |
int force = 0; |
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]) { |
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; |
106 |
|
/* check settings */ |
107 |
|
checkvalues(); |
108 |
|
/* load RIF if any */ |
109 |
< |
if (vdef(RIF)) |
99 |
< |
getradfile(vval(RIF)); |
109 |
> |
getradfile(); |
110 |
|
/* set defaults */ |
111 |
|
setdefaults(&hdg); |
112 |
|
/* holodeck exists? */ |
117 |
|
creatholo(&hdg); |
118 |
|
} else { /* else load holodeck */ |
119 |
|
loadholo(); |
120 |
< |
if (vdef(RIF)) /* load RIF if any */ |
121 |
< |
getradfile(vval(RIF)); |
120 |
> |
/* check settings */ |
121 |
> |
checkvalues(); |
122 |
> |
/* load RIF if any */ |
123 |
> |
getradfile(); |
124 |
> |
/* set defaults */ |
125 |
> |
setdefaults(NULL); |
126 |
|
} |
127 |
|
/* initialize */ |
128 |
|
initrholo(); |
129 |
< |
/* run */ |
129 |
> |
/* main loop */ |
130 |
|
while (rholo()) |
131 |
|
; |
132 |
|
/* done */ |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
+ |
onsig(signo) /* fatal signal */ |
143 |
+ |
int signo; |
144 |
+ |
{ |
145 |
+ |
static int gotsig = 0; |
146 |
+ |
|
147 |
+ |
if (gotsig++) /* two signals and we're gone! */ |
148 |
+ |
_exit(signo); |
149 |
+ |
|
150 |
+ |
alarm(30); /* allow 30 seconds to clean up */ |
151 |
+ |
signal(SIGALRM, SIG_DFL); /* make certain we do die */ |
152 |
+ |
eputs("signal - "); |
153 |
+ |
eputs(sigerr[signo]); |
154 |
+ |
eputs("\n"); |
155 |
+ |
quit(3); |
156 |
+ |
} |
157 |
+ |
|
158 |
+ |
|
159 |
+ |
sigdie(signo, msg) /* set fatal signal */ |
160 |
+ |
int signo; |
161 |
+ |
char *msg; |
162 |
+ |
{ |
163 |
+ |
if (signal(signo, onsig) == SIG_IGN) |
164 |
+ |
signal(signo, SIG_IGN); |
165 |
+ |
sigerr[signo] = msg; |
166 |
+ |
} |
167 |
+ |
|
168 |
+ |
|
169 |
+ |
int |
170 |
+ |
resfmode(fd, mod) /* restrict open file access mode */ |
171 |
+ |
int fd, mod; |
172 |
+ |
{ |
173 |
+ |
struct stat stbuf; |
174 |
+ |
/* get original mode */ |
175 |
+ |
if (fstat(fd, &stbuf) < 0) |
176 |
+ |
error(SYSTEM, "cannot stat open holodeck file"); |
177 |
+ |
mod &= stbuf.st_mode; /* always more restrictive */ |
178 |
+ |
if (mod == stbuf.st_mode) |
179 |
+ |
return(-1); /* already set */ |
180 |
+ |
/* else change it */ |
181 |
+ |
if (fchmod(fd, mod) < 0) { |
182 |
+ |
error(WARNING, "cannot change holodeck file access mode"); |
183 |
+ |
return(-1); |
184 |
+ |
} |
185 |
+ |
return(stbuf.st_mode); /* return original mode */ |
186 |
+ |
} |
187 |
+ |
|
188 |
+ |
|
189 |
|
initrholo() /* get our holodeck running */ |
190 |
|
{ |
191 |
|
extern int global_packet(); |
192 |
|
register int i; |
193 |
+ |
/* close holodeck on exec() */ |
194 |
+ |
fcntl(hdlist[0]->fd, F_SETFD, FD_CLOEXEC); |
195 |
|
|
196 |
|
if (outdev != NULL) /* open output device */ |
197 |
|
disp_open(outdev); |
206 |
|
if (!vdef(TIME) || vflt(TIME) <= FTINY) |
207 |
|
endtime = 0; |
208 |
|
else |
209 |
< |
endtime = starttime + vflt(TIME)*3600.; |
209 |
> |
endtime = starttime + vflt(TIME)*3600. + .5; |
210 |
|
/* set up memory cache */ |
211 |
|
if (outdev == NULL) |
212 |
|
hdcachesize = 0; /* manual flushing */ |
222 |
|
if (ncprocs > 0) { |
223 |
|
i = start_rtrace(); |
224 |
|
if (i < 1) |
225 |
< |
error(USER, "cannot start rtrace process"); |
225 |
> |
error(USER, "cannot start rtrace process(es)"); |
226 |
|
if (vdef(REPORT)) { /* make first report */ |
227 |
|
printargs(rtargc, rtargv, stderr); |
228 |
|
report(0); |
233 |
|
goto memerr; |
234 |
|
freepacks[--i].nr = 0; |
235 |
|
freepacks[i].next = NULL; |
236 |
< |
if (!vbool(OBSTRUCTIONS)) { |
236 |
> |
if (!vdef(OBSTRUCTIONS) || !vbool(OBSTRUCTIONS)) { |
237 |
|
freepacks[i].offset = (float *)bmalloc( |
238 |
|
RPACKSIZ*sizeof(float)*(i+1) ); |
239 |
|
if (freepacks[i].offset == NULL) |
247 |
|
freepacks[i].next = &freepacks[i+1]; |
248 |
|
} |
249 |
|
} |
250 |
+ |
/* set up signal handling */ |
251 |
+ |
sigdie(SIGINT, "Interrupt"); |
252 |
+ |
sigdie(SIGHUP, "Hangup"); |
253 |
+ |
sigdie(SIGTERM, "Terminate"); |
254 |
+ |
sigdie(SIGPIPE, "Broken pipe"); |
255 |
+ |
sigdie(SIGALRM, "Alarm clock"); |
256 |
+ |
#ifdef SIGXCPU |
257 |
+ |
sigdie(SIGXCPU, "CPU limit exceeded"); |
258 |
+ |
sigdie(SIGXFSZ, "File size exceeded"); |
259 |
+ |
#endif |
260 |
+ |
/* protect holodeck file */ |
261 |
+ |
orig_mode = resfmode(hdlist[0]->fd, ncprocs>0 ? 0 : 0444); |
262 |
|
return; |
263 |
|
memerr: |
264 |
|
error(SYSTEM, "out of memory in initrholo"); |
277 |
|
if (!disp_check(idle)) |
278 |
|
return(0); |
279 |
|
/* display only? */ |
280 |
< |
if (ncprocs <= 0) |
281 |
< |
return(1); |
280 |
> |
if (nprocs <= 0) |
281 |
> |
return(outdev != NULL); |
282 |
|
/* check file size */ |
283 |
|
if (maxdisk > 0 && hdfilen(hdlist[0]->fd) >= maxdisk) { |
284 |
|
error(WARNING, "file limit exceeded"); |
285 |
< |
return(0); |
285 |
> |
done_rtrace(); |
286 |
> |
idle = 1; |
287 |
> |
return(1); /* comes back */ |
288 |
|
} |
289 |
|
/* check time */ |
290 |
|
if (endtime > 0 || reporttime > 0) |
291 |
|
t = time(NULL); |
292 |
|
if (endtime > 0 && t >= endtime) { |
293 |
|
error(WARNING, "time limit exceeded"); |
294 |
< |
return(0); |
294 |
> |
done_rtrace(); |
295 |
> |
idle = 1; |
296 |
> |
return(1); /* comes back */ |
297 |
|
} |
298 |
|
if (reporttime > 0 && t >= reporttime) |
299 |
|
report(t); |
302 |
|
p = freepacks; freepacks = p->next; p->next = NULL; |
303 |
|
if (!next_packet(p)) { |
304 |
|
p->next = freepacks; freepacks = p; |
305 |
+ |
idle = 1; |
306 |
|
break; |
307 |
|
} |
308 |
|
if (pl == NULL) pl = p; |
309 |
|
else plend->next = p; |
310 |
|
plend = p; |
311 |
|
} |
312 |
< |
idle = pl == NULL && freepacks != NULL; |
233 |
< |
/* are we out of stuff to do? */ |
234 |
< |
if (idle && outdev == NULL) |
235 |
< |
return(0); |
236 |
< |
/* else process packets */ |
312 |
> |
/* process packets */ |
313 |
|
done_packets(do_packets(pl)); |
314 |
|
return(1); /* and continue */ |
315 |
|
} |
316 |
|
|
317 |
|
|
242 |
– |
report(t) /* report progress so far */ |
243 |
– |
time_t t; |
244 |
– |
{ |
245 |
– |
if (t == 0) |
246 |
– |
t = time(NULL); |
247 |
– |
fprintf(stderr, "%s: %ld packets (%ld rays) done after %.2f hours\n", |
248 |
– |
progname, npacksdone, nraysdone, (t-starttime)/3600.); |
249 |
– |
fflush(stderr); |
250 |
– |
if (vdef(REPORT)) |
251 |
– |
reporttime = t + (time_t)(vflt(REPORT)*60.+.5); |
252 |
– |
} |
253 |
– |
|
254 |
– |
|
318 |
|
setdefaults(gp) /* set default values */ |
319 |
|
register HDGRID *gp; |
320 |
|
{ |
331 |
|
sprintf(errmsg, "ignoring all but first %s", vnam(SECTION)); |
332 |
|
error(WARNING, errmsg); |
333 |
|
} |
334 |
+ |
if (!vdef(OCTREE)) { |
335 |
+ |
if ((vval(OCTREE) = bmalloc(strlen(froot)+5)) == NULL) |
336 |
+ |
error(SYSTEM, "out of memory"); |
337 |
+ |
sprintf(vval(OCTREE), "%s.oct", froot); |
338 |
+ |
vdef(OCTREE)++; |
339 |
+ |
} |
340 |
+ |
if (!vdef(VDIST)) { |
341 |
+ |
vval(VDIST) = "F"; |
342 |
+ |
vdef(VDIST)++; |
343 |
+ |
} |
344 |
+ |
if (!vdef(OCCUPANCY)) { |
345 |
+ |
vval(OCCUPANCY) = "U"; |
346 |
+ |
vdef(OCCUPANCY)++; |
347 |
+ |
} |
348 |
+ |
/* append rendering options */ |
349 |
+ |
if (vdef(RENDER)) |
350 |
+ |
rtargc += wordstring(rtargv+rtargc, vval(RENDER)); |
351 |
+ |
|
352 |
+ |
if (gp == NULL) /* already initialized? */ |
353 |
+ |
return; |
354 |
+ |
/* set grid parameters */ |
355 |
+ |
gp->grid[0] = gp->grid[1] = gp->grid[2] = 0; |
356 |
|
if (sscanf(vval(SECTION), |
357 |
< |
"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", |
357 |
> |
"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %hd %hd %hd", |
358 |
|
&gp->orig[0], &gp->orig[1], &gp->orig[2], |
359 |
|
&gp->xv[0][0], &gp->xv[0][1], &gp->xv[0][2], |
360 |
|
&gp->xv[1][0], &gp->xv[1][1], &gp->xv[1][2], |
361 |
< |
&gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2]) != 12) |
361 |
> |
&gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2], |
362 |
> |
&gp->grid[0], &gp->grid[1], &gp->grid[2]) < 12) |
363 |
|
badvalue(SECTION); |
364 |
|
maxlen = 0.; |
365 |
|
for (i = 0; i < 3; i++) |
373 |
|
if ((d = vflt(GRID)) <= FTINY) |
374 |
|
badvalue(GRID); |
375 |
|
for (i = 0; i < 3; i++) |
376 |
< |
gp->grid[i] = len[i]/d + (1.-FTINY); |
377 |
< |
if (!vdef(EXPOSURE)) { |
292 |
< |
sprintf(errmsg, "%s must be defined", vnam(EXPOSURE)); |
293 |
< |
error(USER, errmsg); |
294 |
< |
} |
295 |
< |
expval = vval(EXPOSURE)[0] == '-' || vval(EXPOSURE)[0] == '+' ? |
296 |
< |
pow(2., vflt(EXPOSURE)) : vflt(EXPOSURE); |
297 |
< |
if (!vdef(OCTREE)) { |
298 |
< |
if ((vval(OCTREE) = bmalloc(strlen(froot)+5)) == NULL) |
299 |
< |
error(SYSTEM, "out of memory"); |
300 |
< |
sprintf(vval(OCTREE), "%s.oct", froot); |
301 |
< |
vdef(OCTREE)++; |
302 |
< |
} |
303 |
< |
if (!vdef(OBSTRUCTIONS)) { |
304 |
< |
vval(OBSTRUCTIONS) = "T"; |
305 |
< |
vdef(OBSTRUCTIONS)++; |
306 |
< |
} |
307 |
< |
if (!vdef(OCCUPANCY)) { |
308 |
< |
vval(OCCUPANCY) = "U"; |
309 |
< |
vdef(OCCUPANCY)++; |
310 |
< |
} |
311 |
< |
/* append rendering options */ |
312 |
< |
if (vdef(RENDER)) |
313 |
< |
rtargc += wordstring(rtargv+rtargc, vval(RENDER)); |
376 |
> |
if (gp->grid[i] <= 0) |
377 |
> |
gp->grid[i] = len[i]/d + (1.-FTINY); |
378 |
|
} |
379 |
|
|
380 |
|
|
381 |
|
creatholo(gp) /* create a holodeck output file */ |
382 |
|
HDGRID *gp; |
383 |
|
{ |
384 |
+ |
extern char VersionID[]; |
385 |
|
long endloc = 0; |
386 |
+ |
int fd; |
387 |
|
FILE *fp; |
388 |
|
/* open & truncate file */ |
389 |
|
if ((fp = fopen(hdkfile, "w+")) == NULL) { |
392 |
|
} |
393 |
|
/* write information header */ |
394 |
|
newheader("RADIANCE", fp); |
395 |
+ |
fprintf(fp, "SOFTWARE= %s\n", VersionID); |
396 |
|
printvars(fp); |
397 |
|
fputformat(HOLOFMT, fp); |
398 |
|
fputc('\n', fp); |
399 |
|
putw(HOLOMAGIC, fp); /* put magic number & terminus */ |
400 |
|
fwrite(&endloc, sizeof(long), 1, fp); |
401 |
< |
fflush(fp); /* flush buffer */ |
402 |
< |
hdinit(fileno(fp), gp); /* allocate and initialize index */ |
403 |
< |
/* we're dropping fp here.... */ |
401 |
> |
fd = dup(fileno(fp)); |
402 |
> |
fclose(fp); /* flush and close stdio stream */ |
403 |
> |
hdinit(fd, gp); /* allocate and initialize index */ |
404 |
|
} |
405 |
|
|
406 |
|
|
430 |
|
|
431 |
|
loadholo() /* start loading a holodeck from fname */ |
432 |
|
{ |
433 |
+ |
extern long ftell(); |
434 |
|
FILE *fp; |
435 |
< |
long endloc; |
435 |
> |
int fd; |
436 |
> |
long fpos; |
437 |
|
/* open holodeck file */ |
438 |
|
if ((fp = fopen(hdkfile, ncprocs>0 ? "r+" : "r")) == NULL) { |
439 |
|
sprintf(errmsg, "cannot open \"%s\" for %s", hdkfile, |
448 |
|
hdkfile); |
449 |
|
error(USER, errmsg); |
450 |
|
} |
451 |
< |
fread(&endloc, sizeof(long), 1, fp); |
452 |
< |
if (endloc != 0) |
451 |
> |
fread(&fpos, sizeof(long), 1, fp); |
452 |
> |
if (fpos != 0) |
453 |
|
error(WARNING, "ignoring multiple sections in holodeck file"); |
454 |
< |
fseek(fp, 0L, 1); /* align system file pointer */ |
455 |
< |
hdinit(fileno(fp), NULL); /* allocate and load index */ |
456 |
< |
/* we're dropping fp here.... */ |
454 |
> |
fpos = ftell(fp); /* get stdio position */ |
455 |
> |
fd = dup(fileno(fp)); |
456 |
> |
fclose(fp); /* done with stdio */ |
457 |
> |
lseek(fd, fpos, 0); /* align system file pointer */ |
458 |
> |
hdinit(fd, NULL); /* allocate and load index */ |
459 |
|
} |
460 |
|
|
461 |
|
|
462 |
|
done_packets(pl) /* handle finished packets */ |
463 |
|
PACKET *pl; |
464 |
|
{ |
465 |
< |
static int nunflushed = 0; |
465 |
> |
static int n2flush = 0; |
466 |
|
register PACKET *p; |
467 |
|
|
468 |
|
while (pl != NULL) { |
473 |
|
p->nr*sizeof(RAYVAL)); |
474 |
|
if (outdev != NULL) /* display it */ |
475 |
|
disp_packet((PACKHEAD *)p); |
476 |
< |
else |
477 |
< |
nunflushed += p->nr; |
476 |
> |
if (hdcachesize <= 0) /* manual flushing */ |
477 |
> |
n2flush += p->nr; |
478 |
|
nraysdone += p->nr; |
479 |
|
npacksdone++; |
480 |
|
} |
482 |
|
p->next = freepacks; |
483 |
|
freepacks = p; |
484 |
|
} |
485 |
< |
if (nunflushed >= 256*RPACKSIZ) { |
485 |
> |
if (n2flush > 512*RPACKSIZ*nprocs) { |
486 |
|
hdflush(NULL); /* flush holodeck buffers */ |
487 |
< |
nunflushed = 0; |
487 |
> |
n2flush = 0; |
488 |
|
} |
489 |
|
} |
490 |
|
|
491 |
|
|
421 |
– |
getradfile(rfargs) /* run rad and get needed variables */ |
422 |
– |
char *rfargs; |
423 |
– |
{ |
424 |
– |
static short mvar[] = {OCTREE,EXPOSURE,-1}; |
425 |
– |
static char tf1[] = TEMPLATE; |
426 |
– |
char tf2[64]; |
427 |
– |
char combuf[256]; |
428 |
– |
char *pippt; |
429 |
– |
register int i; |
430 |
– |
register char *cp; |
431 |
– |
/* create rad command */ |
432 |
– |
mktemp(tf1); |
433 |
– |
sprintf(tf2, "%s.rif", tf1); |
434 |
– |
sprintf(combuf, |
435 |
– |
"rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH", |
436 |
– |
rfargs, tf1); |
437 |
– |
cp = combuf; |
438 |
– |
while (*cp){ |
439 |
– |
if (*cp == '|') pippt = cp; |
440 |
– |
cp++; |
441 |
– |
} /* match unset variables */ |
442 |
– |
for (i = 0; mvar[i] >= 0; i++) |
443 |
– |
if (!vdef(mvar[i])) { |
444 |
– |
*cp++ = '|'; |
445 |
– |
strcpy(cp, vnam(mvar[i])); |
446 |
– |
while (*cp) cp++; |
447 |
– |
pippt = NULL; |
448 |
– |
} |
449 |
– |
if (pippt != NULL) |
450 |
– |
strcpy(pippt, "> /dev/null"); /* nothing to match */ |
451 |
– |
else |
452 |
– |
sprintf(cp, ")[ \t]*=' > %s", tf2); |
453 |
– |
if (system(combuf)) { |
454 |
– |
error(SYSTEM, "cannot execute rad command"); |
455 |
– |
unlink(tf2); /* clean up */ |
456 |
– |
unlink(tf1); |
457 |
– |
quit(1); |
458 |
– |
} |
459 |
– |
if (pippt == NULL) { |
460 |
– |
loadvars(tf2); /* load variables */ |
461 |
– |
unlink(tf2); |
462 |
– |
} |
463 |
– |
rtargc += wordfile(rtargv+rtargc, tf1); /* get rtrace options */ |
464 |
– |
unlink(tf1); /* clean up */ |
465 |
– |
} |
466 |
– |
|
467 |
– |
|
492 |
|
rootname(rn, fn) /* remove tail from end of fn */ |
493 |
|
register char *rn, *fn; |
494 |
|
{ |
495 |
|
char *tp, *dp; |
496 |
|
|
497 |
|
for (tp = NULL, dp = rn; *rn = *fn++; rn++) |
498 |
< |
if (ISDIRSEP(*rn)) |
498 |
> |
if (*rn == '/') |
499 |
|
dp = rn; |
500 |
|
else if (*rn == '.') |
501 |
|
tp = rn; |
544 |
|
{ |
545 |
|
int status = 0; |
546 |
|
|
547 |
< |
if (outdev != NULL) /* close display */ |
548 |
< |
disp_close(); |
549 |
< |
if (hdlist[0] != NULL) { /* flush holodeck */ |
550 |
< |
if (ncprocs > 0) { |
551 |
< |
done_packets(flush_queue()); |
552 |
< |
status = end_rtrace(); /* close rtrace */ |
553 |
< |
hdflush(NULL); |
554 |
< |
if (vdef(REPORT)) { |
531 |
< |
long fsiz, fuse; |
532 |
< |
report(0); |
533 |
< |
fsiz = hdfilen(hdlist[0]->fd); |
534 |
< |
fuse = hdfiluse(hdlist[0]->fd, 1); |
535 |
< |
fprintf(stderr, |
547 |
> |
if (hdlist[0] != NULL) { /* close holodeck */ |
548 |
> |
if (nprocs > 0) |
549 |
> |
status = done_rtrace(); /* calls hdsync() */ |
550 |
> |
if (ncprocs > 0 && vdef(REPORT)) { |
551 |
> |
long fsiz, fuse; |
552 |
> |
fsiz = hdfilen(hdlist[0]->fd); |
553 |
> |
fuse = hdfiluse(hdlist[0]->fd, 1); |
554 |
> |
fprintf(stderr, |
555 |
|
"%s: %.1f Mbyte holodeck file, %.1f%% fragmentation\n", |
556 |
< |
hdkfile, fsiz/(1024.*1024.), |
557 |
< |
100.*(fsiz-fuse)/fsiz); |
558 |
< |
} |
540 |
< |
} else |
541 |
< |
hdflush(NULL); |
556 |
> |
hdkfile, fsiz/(1024.*1024.), |
557 |
> |
100.*(fsiz-fuse)/fsiz); |
558 |
> |
} |
559 |
|
} |
560 |
+ |
if (orig_mode >= 0) /* reset holodeck access mode */ |
561 |
+ |
fchmod(hdlist[0]->fd, orig_mode); |
562 |
+ |
if (outdev != NULL) /* close display */ |
563 |
+ |
disp_close(); |
564 |
|
exit(ec ? ec : status); /* exit */ |
565 |
|
} |