ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rpiece.c
Revision: 2.52
Committed: Fri May 28 22:36:19 2010 UTC (13 years, 11 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad4R1
Changes since 2.51: +2 -1 lines
Log Message:
Added date to rpiece header output

File Contents

# User Rev Content
1 greg 2.1 #ifndef lint
2 greg 2.52 static const char RCSid[] = "$Id: rpiece.c,v 2.51 2010/05/17 17:03:53 greg Exp $";
3 greg 2.1 #endif
4     /*
5     * Generate sections of a picture.
6     */
7    
8 schorsch 2.43
9     #include <stdio.h>
10     #include <signal.h>
11     #include <sys/types.h>
12 schorsch 2.49
13     #include "platform.h"
14 schorsch 2.45 #ifndef NON_POSIX /* XXX need abstraction for process management */
15     #include <sys/wait.h>
16     #endif
17 schorsch 2.43
18 greg 2.44 #include "standard.h"
19 schorsch 2.43 #include "color.h"
20     #include "view.h"
21     #include "rtprocess.h"
22 greg 2.16
23     #ifndef F_SETLKW
24    
25 schorsch 2.43 int
26     main(
27     int argc,
28     char *argv[]
29     )
30 greg 2.16 {
31     fprintf(stderr, "%s: no NFS lock manager on this machine\n", argv[0]);
32     exit(1);
33     }
34    
35     #else
36    
37 greg 2.12 #ifndef NFS
38     #define NFS 1
39     #endif
40 greg 2.9 /* set the following to 0 to forgo forking */
41     #ifndef MAXFORK
42 greg 2.12 #if NFS
43 greg 2.10 #define MAXFORK 3 /* allotment of duped processes */
44 greg 2.12 #else
45     #define MAXFORK 0
46 greg 2.9 #endif
47 greg 2.12 #endif
48 greg 2.18 /* protection from SYSV signals(!) */
49 greg 2.27 #if defined(sgi)
50 greg 2.18 #define guard_io() sighold(SIGALRM)
51     #define unguard() sigrelse(SIGALRM)
52     #endif
53     #ifndef guard_io
54 schorsch 2.43 #define guard_io()
55     #define unguard()
56 greg 2.18 #endif
57 gregl 2.34
58 greg 2.37 extern char *strerror();
59 gregl 2.34
60 greg 2.1 /* rpict command */
61 greg 2.23 char *rpargv[128] = {"rpict", "-S", "1"};
62     int rpargc = 3;
63 greg 2.1 FILE *torp, *fromrp;
64 greg 2.8 COLR *pbuf;
65 greg 2.1 /* our view parameters */
66     VIEW ourview = STDVIEW;
67 greg 2.4 double pixaspect = 1.0;
68 greg 2.23 int hres = 1024, vres = 1024, hmult = 4, vmult = 4;
69 greg 2.1 /* output file */
70     char *outfile = NULL;
71     int outfd;
72     long scanorig;
73 greg 2.25 FILE *syncfp = NULL; /* synchronization file pointer */
74     int synclst = F_UNLCK; /* synchronization file lock status */
75 greg 2.9 int nforked = 0;
76 greg 2.1
77 greg 2.25 #define sflock(t) if ((t)!=synclst) dolock(fileno(syncfp),synclst=t)
78    
79 greg 2.1 char *progname;
80     int verbose = 0;
81 greg 2.31 unsigned timelim = 0;
82 greg 2.25 int rvrlim = -1;
83 greg 2.1
84 greg 2.6 int gotalrm = 0;
85 schorsch 2.38 void onalrm(int i) { gotalrm++; }
86 greg 2.1
87 schorsch 2.43 static void dolock(int fd, int ltyp);
88     static void init(int ac, char **av);
89     static int nextpiece(int *xp, int *yp);
90     static int rvrpiece(int *xp, int *yp);
91     static int cleanup(int rstat);
92     static void rpiece(void);
93     static int putpiece(int xpos, int ypos);
94     static void filerr(char *t);
95 greg 2.6
96 schorsch 2.43
97     int
98     main(
99     int argc,
100     char *argv[]
101     )
102 greg 2.1 {
103     register int i, rval;
104    
105     progname = argv[0];
106     for (i = 1; i < argc; i++) {
107 greg 2.22 /* expand arguments */
108 greg 2.37 while ((rval = expandarg(&argc, &argv, i)) > 0)
109     ;
110     if (rval < 0) {
111 greg 2.50 fprintf(stderr, "%s: cannot expand '%s'\n",
112 greg 2.37 argv[0], argv[i]);
113     exit(1);
114     }
115 greg 2.1 if (argv[i][0] == '-')
116     switch (argv[i][1]) {
117     case 'v':
118     switch (argv[i][2]) {
119     case '\0': /* verbose option */
120     verbose = !verbose;
121     continue;
122     case 'f': /* view file */
123     if (viewfile(argv[++i], &ourview, NULL) <= 0) {
124     fprintf(stderr,
125     "%s: not a view file\n", argv[i]);
126     exit(1);
127     }
128     continue;
129     default: /* view option? */
130     rval = getviewopt(&ourview, argc-i, argv+i);
131     if (rval >= 0) {
132     i += rval;
133     continue;
134     }
135     break;
136     }
137     break;
138     case 'p': /* pixel aspect ratio? */
139 greg 2.51 if (argv[i][2] == 'm') {
140     fprintf(stderr, "%s: -pm unsupported\n",
141     argv[0]);
142     ++i;
143     continue;
144     }
145 greg 2.23 if (argv[i][2] != 'a' || argv[i][3])
146     break;
147 gregl 2.35 pixaspect = atof(argv[++i]);
148 greg 2.23 continue;
149 greg 2.31 case 'T': /* time limit (hours) */
150     if (argv[i][2])
151     break;
152     timelim = atof(argv[++i])*3600. + .5;
153 greg 2.51 continue;
154 greg 2.23 case 'x': /* overall x resolution */
155     if (argv[i][2])
156     break;
157     hres = atoi(argv[++i]);
158     continue;
159     case 'y': /* overall y resolution */
160     if (argv[i][2])
161     break;
162     vres = atoi(argv[++i]);
163     continue;
164 greg 2.1 case 'X': /* horizontal multiplier */
165     if (argv[i][2])
166     break;
167     hmult = atoi(argv[++i]);
168     continue;
169     case 'Y': /* vertical multiplier */
170     if (argv[i][2])
171     break;
172     vmult = atoi(argv[++i]);
173     continue;
174 greg 2.25 case 'R': /* recover */
175     if (argv[i][2])
176     break;
177     rvrlim = 0;
178     /* fall through */
179 greg 2.5 case 'F': /* syncronization file */
180     if (argv[i][2])
181     break;
182 greg 2.28 if ((syncfp =
183     fdopen(open(argv[++i],O_RDWR|O_CREAT,0666),"r+")) == NULL) {
184 greg 2.5 fprintf(stderr, "%s: cannot open\n",
185     argv[i]);
186     exit(1);
187     }
188     continue;
189 greg 2.15 case 'z': /* z-file ist verbotten */
190     fprintf(stderr, "%s: -z option not allowed\n",
191     argv[0]);
192     exit(1);
193 greg 2.1 case 'o': /* output file */
194     if (argv[i][2])
195     break;
196     outfile = argv[++i];
197     continue;
198 greg 2.23 } else if (i >= argc-1)
199     break;
200 greg 2.1 rpargv[rpargc++] = argv[i];
201     }
202 greg 2.23 if (i >= argc) {
203     fprintf(stderr, "%s: missing octree argument\n", argv[0]);
204     exit(1);
205     }
206 greg 2.1 if (outfile == NULL) {
207     fprintf(stderr, "%s: missing output file\n", argv[0]);
208     exit(1);
209     }
210     init(argc, argv);
211     rpiece();
212 greg 2.15 exit(cleanup(0));
213 greg 2.1 }
214    
215    
216 schorsch 2.43 static void
217     dolock( /* lock or unlock a file */
218     int fd,
219     int ltyp
220     )
221 greg 2.25 {
222     static struct flock fls; /* static so initialized to zeroes */
223    
224     fls.l_type = ltyp;
225     if (fcntl(fd, F_SETLKW, &fls) < 0) {
226 greg 2.28 fprintf(stderr, "%s: cannot lock/unlock file: %s\n",
227 greg 2.37 progname, strerror(errno));
228 greg 2.25 exit(1);
229     }
230     }
231    
232    
233 schorsch 2.43 static void
234     init( /* set up output file and start rpict */
235     int ac,
236     char **av
237     )
238 greg 2.1 {
239 greg 2.23 static char hrbuf[16], vrbuf[16];
240 greg 2.2 extern char VersionID[];
241 greg 2.1 char *err;
242     FILE *fp;
243     int hr, vr;
244 schorsch 2.39 SUBPROC rpd; /* since we don't close_process(), this can be local */
245 greg 2.1 /* set up view */
246     if ((err = setview(&ourview)) != NULL) {
247     fprintf(stderr, "%s: %s\n", progname, err);
248     exit(1);
249     }
250 greg 2.25 if (syncfp != NULL) {
251     sflock(F_RDLCK);
252     fscanf(syncfp, "%d %d", &hmult, &vmult);
253     sflock(F_UNLCK);
254 greg 2.5 }
255 greg 2.23 /* compute piece size */
256     hres /= hmult;
257     vres /= vmult;
258 greg 2.46 if (hres <= 0 || vres <= 0) {
259 greg 2.47 fprintf(stderr, "%s: illegal resolution/subdivision\n", progname);
260 greg 2.46 exit(1);
261     }
262 greg 2.1 normaspect(viewaspect(&ourview)*hmult/vmult, &pixaspect, &hres, &vres);
263 greg 2.23 sprintf(hrbuf, "%d", hres);
264     rpargv[rpargc++] = "-x"; rpargv[rpargc++] = hrbuf;
265     sprintf(vrbuf, "%d", vres);
266     rpargv[rpargc++] = "-y"; rpargv[rpargc++] = vrbuf;
267     rpargv[rpargc++] = "-pa"; rpargv[rpargc++] = "0";
268     rpargv[rpargc++] = av[ac-1];
269     rpargv[rpargc] = NULL;
270 greg 2.1 /* open output file */
271     if ((outfd = open(outfile, O_WRONLY|O_CREAT|O_EXCL, 0666)) >= 0) {
272 greg 2.25 dolock(outfd, F_WRLCK);
273 greg 2.1 if ((fp = fdopen(dup(outfd), "w")) == NULL)
274     goto filerr;
275 greg 2.29 newheader("RADIANCE", fp); /* create header */
276     printargs(ac, av, fp);
277 greg 2.2 fprintf(fp, "SOFTWARE= %s\n", VersionID);
278 greg 2.1 fputs(VIEWSTR, fp);
279     fprintview(&ourview, fp);
280     putc('\n', fp);
281 greg 2.52 fputnow(fp);
282 greg 2.1 if (pixaspect < .99 || pixaspect > 1.01)
283     fputaspect(pixaspect, fp);
284     fputformat(COLRFMT, fp);
285     putc('\n', fp);
286     fprtresolu(hres*hmult, vres*vmult, fp);
287     } else if ((outfd = open(outfile, O_RDWR)) >= 0) {
288 greg 2.25 dolock(outfd, F_RDLCK);
289 greg 2.1 if ((fp = fdopen(dup(outfd), "r+")) == NULL)
290     goto filerr;
291 greg 2.13 getheader(fp, NULL, NULL); /* skip header */
292 greg 2.15 if (!fscnresolu(&hr, &vr, fp) || /* check resolution */
293 greg 2.1 hr != hres*hmult || vr != vres*vmult) {
294 greg 2.8 fprintf(stderr, "%s: resolution mismatch on file \"%s\"\n",
295     progname, outfile);
296 greg 2.1 exit(1);
297     }
298     } else {
299 greg 2.8 fprintf(stderr, "%s: cannot open file \"%s\"\n",
300     progname, outfile);
301 greg 2.1 exit(1);
302     }
303     scanorig = ftell(fp); /* record position of first scanline */
304     if (fclose(fp) == -1) /* done with stream i/o */
305     goto filerr;
306 greg 2.25 dolock(outfd, F_UNLCK);
307 greg 2.1 /* start rpict process */
308 schorsch 2.39 if (open_process(&rpd, rpargv) <= 0) {
309 greg 2.3 fprintf(stderr, "%s: cannot start %s\n", progname, rpargv[0]);
310 greg 2.1 exit(1);
311     }
312 schorsch 2.39 if ((fromrp = fdopen(rpd.r, "r")) == NULL ||
313     (torp = fdopen(rpd.w, "w")) == NULL) {
314 greg 2.1 fprintf(stderr, "%s: cannot open stream to %s\n",
315     progname, rpargv[0]);
316     exit(1);
317     }
318 greg 2.23 if ((pbuf = (COLR *)bmalloc(hres*vres*sizeof(COLR))) == NULL) {
319 greg 2.1 fprintf(stderr, "%s: out of memory\n", progname);
320     exit(1);
321     }
322 greg 2.6 signal(SIGALRM, onalrm);
323 greg 2.31 if (timelim)
324     alarm(timelim);
325 greg 2.1 return;
326     filerr:
327 greg 2.8 fprintf(stderr, "%s: i/o error on file \"%s\"\n", progname, outfile);
328 greg 2.1 exit(1);
329     }
330    
331    
332 schorsch 2.43 static int
333     nextpiece( /* get next piece assignment */
334     int *xp,
335     int *yp
336     )
337 greg 2.5 {
338 greg 2.6 if (gotalrm) /* someone wants us to quit */
339     return(0);
340 greg 2.25 if (syncfp != NULL) { /* use sync file */
341     /*
342     * So we don't necessarily have to lock and unlock the file
343     * multiple times (very slow), we establish an exclusive
344     * lock at the beginning on our synchronization file and
345     * maintain it in the subroutine rvrpiece().
346     */
347     sflock(F_WRLCK);
348     fseek(syncfp, 0L, 0); /* read position */
349     if (fscanf(syncfp, "%*d %*d %d %d", xp, yp) < 2) {
350 greg 2.8 *xp = hmult-1;
351     *yp = vmult;
352     }
353 greg 2.25 if (rvrlim == 0) /* initialize recovery limit */
354     rvrlim = *xp*vmult + *yp;
355     if (rvrpiece(xp, yp)) { /* do stragglers first */
356     sflock(F_UNLCK);
357     return(1);
358     }
359 greg 2.8 if (--(*yp) < 0) { /* decrement position */
360 greg 2.5 *yp = vmult-1;
361 greg 2.25 if (--(*xp) < 0) { /* all done */
362     sflock(F_UNLCK);
363 greg 2.5 return(0);
364     }
365     }
366 greg 2.25 fseek(syncfp, 0L, 0); /* write new position */
367     fprintf(syncfp, "%4d %4d\n%4d %4d\n\n", hmult, vmult, *xp, *yp);
368     fflush(syncfp);
369     sflock(F_UNLCK); /* release sync file */
370 greg 2.5 return(1);
371     }
372 greg 2.26 return(scanf("%d %d", xp, yp) == 2); /* use stdin */
373 greg 2.5 }
374    
375    
376 schorsch 2.43 static int
377     rvrpiece( /* check for recoverable pieces */
378     register int *xp,
379     register int *yp
380     )
381 greg 2.25 {
382     static char *pdone = NULL; /* which pieces are done */
383     static long readpos = -1; /* how far we've read */
384     register int i;
385     /*
386     * This routine is called by nextpiece() with an
387     * exclusive lock on syncfp and the file pointer at the
388     * appropriate position to read in the finished pieces.
389     */
390     if (rvrlim < 0)
391     return(0); /* only check if asked */
392     if (pdone == NULL) /* first call */
393     pdone = calloc(hmult*vmult, sizeof(char));
394 greg 2.30 if (pdone == NULL) {
395     fprintf(stderr, "%s: out of memory\n", progname);
396     exit(1);
397     }
398 greg 2.25 if (readpos != -1) /* mark what's been done */
399     fseek(syncfp, readpos, 0);
400     while (fscanf(syncfp, "%d %d", xp, yp) == 2)
401     pdone[*xp*vmult+*yp] = 1;
402     if (!feof(syncfp)) {
403     fprintf(stderr, "%s: format error in sync file\n", progname);
404     exit(1);
405     }
406     readpos = ftell(syncfp);
407     i = hmult*vmult; /* find an unaccounted for piece */
408     while (i-- > rvrlim)
409     if (!pdone[i]) {
410     *xp = i / vmult;
411     *yp = i % vmult;
412     pdone[i] = 1; /* consider it done */
413     return(1);
414     }
415     rvrlim = -1; /* nothing left to recover */
416     free(pdone);
417     pdone = NULL;
418     return(0);
419     }
420    
421    
422 schorsch 2.43 static int
423     cleanup( /* close rpict process and clean up */
424     int rstat
425     )
426 greg 2.1 {
427 greg 2.10 int status;
428 greg 2.1
429 greg 2.23 bfree((char *)pbuf, hres*vres*sizeof(COLR));
430 greg 2.1 fclose(torp);
431     fclose(fromrp);
432 greg 2.10 while (wait(&status) != -1)
433 greg 2.9 if (rstat == 0)
434     rstat = status>>8 & 0xff;
435     return(rstat);
436 greg 2.1 }
437    
438    
439 schorsch 2.43 static void
440     rpiece(void) /* render picture piece by piece */
441 greg 2.1 {
442     VIEW pview;
443     int xorg, yorg;
444 greg 2.11 /* compute view parameters */
445 schorsch 2.40 pview = ourview;
446 greg 2.11 switch (ourview.type) {
447     case VT_PER:
448 greg 2.48 pview.horiz = (2.*180./PI)*atan(
449     tan((PI/180./2.)*ourview.horiz)/hmult );
450     pview.vert = (2.*180./PI)*atan(
451     tan((PI/180./2.)*ourview.vert)/vmult );
452 greg 2.11 break;
453     case VT_PAR:
454     case VT_ANG:
455     pview.horiz = ourview.horiz / hmult;
456     pview.vert = ourview.vert / vmult;
457     break;
458 greg 2.32 case VT_CYL:
459     pview.horiz = ourview.horiz / hmult;
460 greg 2.48 pview.vert = (2.*180./PI)*atan(
461     tan((PI/180./2.)*ourview.vert)/vmult );
462 greg 2.32 break;
463 greg 2.11 case VT_HEM:
464 greg 2.48 pview.horiz = (2.*180./PI)*asin(
465     sin((PI/180./2.)*ourview.horiz)/hmult );
466     pview.vert = (2.*180./PI)*asin(
467     sin((PI/180./2.)*ourview.vert)/vmult );
468     break;
469     case VT_PLS:
470     pview.horiz = sin((PI/180./2.)*ourview.horiz) /
471     (1.0 + cos((PI/180./2.)*ourview.horiz)) / hmult;
472     pview.horiz *= pview.horiz;
473     pview.horiz = (2.*180./PI)*acos((1. - pview.horiz) /
474     (1. + pview.horiz));
475     pview.vert = sin((PI/180./2.)*ourview.vert) /
476     (1.0 + cos((PI/180./2.)*ourview.vert)) / vmult;
477     pview.vert *= pview.vert;
478     pview.vert = (2.*180./PI)*acos((1. - pview.vert) /
479     (1. + pview.vert));
480 greg 2.11 break;
481     default:
482     fprintf(stderr, "%s: unknown view type '-vt%c'\n",
483     progname, ourview.type);
484     exit(cleanup(1));
485     }
486     /* render each piece */
487 greg 2.5 while (nextpiece(&xorg, &yorg)) {
488 gregl 2.33 pview.hoff = ourview.hoff*hmult + xorg - 0.5*(hmult-1);
489     pview.voff = ourview.voff*vmult + yorg - 0.5*(vmult-1);
490 greg 2.1 fputs(VIEWSTR, torp);
491     fprintview(&pview, torp);
492     putc('\n', torp);
493 greg 2.11 fflush(torp); /* assigns piece to rpict */
494 greg 2.1 putpiece(xorg, yorg); /* place piece in output */
495     }
496     }
497    
498    
499 schorsch 2.43 static int
500     putpiece( /* get next piece from rpict */
501     int xpos,
502     int ypos
503     )
504 greg 2.1 {
505 greg 2.7 struct flock fls;
506 greg 2.9 int pid, status;
507 greg 2.1 int hr, vr;
508 greg 2.8 register int y;
509     /* check bounds */
510 schorsch 2.41 if ((xpos < 0) | (ypos < 0) | (xpos >= hmult) | (ypos >= vmult)) {
511 greg 2.5 fprintf(stderr, "%s: requested piece (%d,%d) out of range\n",
512     progname, xpos, ypos);
513 greg 2.10 exit(cleanup(1));
514 greg 2.5 }
515 greg 2.8 /* check header from rpict */
516 greg 2.18 guard_io();
517 greg 2.13 getheader(fromrp, NULL, NULL);
518 schorsch 2.41 if (!fscnresolu(&hr, &vr, fromrp) || (hr != hres) | (vr != vres)) {
519 greg 2.3 fprintf(stderr, "%s: resolution mismatch from %s\n",
520     progname, rpargv[0]);
521 greg 2.10 exit(cleanup(1));
522 greg 2.1 }
523 greg 2.24 if (verbose) { /* notify caller */
524     printf("%d %d begun\n", xpos, ypos);
525     fflush(stdout);
526     }
527 greg 2.18 unguard();
528 greg 2.8 /* load new piece into buffer */
529 greg 2.18 for (y = 0; y < vr; y++) {
530     guard_io();
531 greg 2.8 if (freadcolrs(pbuf+y*hr, hr, fromrp) < 0) {
532 greg 2.3 fprintf(stderr, "%s: read error from %s\n",
533     progname, rpargv[0]);
534 greg 2.10 exit(cleanup(1));
535 greg 2.1 }
536 greg 2.18 unguard();
537     }
538 greg 2.9 #if MAXFORK
539     /* fork so we don't slow rpict down */
540     if ((pid = fork()) > 0) {
541 greg 2.10 if (++nforked >= MAXFORK) {
542 greg 2.9 wait(&status); /* reap a child */
543     if (status)
544 greg 2.10 exit(cleanup(status>>8 & 0xff));
545 greg 2.9 nforked--;
546     }
547     return(pid);
548     }
549     #else
550     pid = -1; /* no forking */
551     #endif
552 greg 2.19 fls.l_start = scanorig +
553     ((long)(vmult-1-ypos)*vres*hmult+xpos)*hres*sizeof(COLR);
554 greg 2.12 #if NFS
555 greg 2.19 fls.l_len = ((long)(vres-1)*hmult+1)*hres*sizeof(COLR);
556 greg 2.8 /* lock file section so NFS doesn't mess up */
557     fls.l_whence = 0;
558     fls.l_type = F_WRLCK;
559 greg 2.26 if (fcntl(outfd, F_SETLKW, &fls) < 0)
560     filerr("lock");
561 greg 2.12 #endif
562 greg 2.8 /* write new piece to file */
563 greg 2.42 if (lseek(outfd, (off_t)fls.l_start, SEEK_SET) < 0)
564 greg 2.26 filerr("seek");
565 greg 2.9 if (hmult == 1) {
566     if (writebuf(outfd, (char *)pbuf,
567     vr*hr*sizeof(COLR)) != vr*hr*sizeof(COLR))
568 greg 2.26 filerr("write");
569 greg 2.9 } else
570     for (y = 0; y < vr; y++) {
571     if (writebuf(outfd, (char *)(pbuf+y*hr),
572     hr*sizeof(COLR)) != hr*sizeof(COLR))
573 greg 2.26 filerr("write");
574 greg 2.9 if (y < vr-1 && lseek(outfd,
575 greg 2.37 (off_t)(hmult-1)*hr*sizeof(COLR),
576 greg 2.42 SEEK_CUR) < 0)
577 greg 2.26 filerr("seek");
578 greg 2.1 }
579 greg 2.25 #if NFS
580     fls.l_type = F_UNLCK; /* release lock */
581 greg 2.26 if (fcntl(outfd, F_SETLKW, &fls) < 0)
582     filerr("lock");
583 greg 2.25 #endif
584 greg 2.32 if (verbose) { /* notify caller */
585     printf("%d %d done\n", xpos, ypos);
586     fflush(stdout);
587     }
588 greg 2.25 if (syncfp != NULL) { /* record what's been done */
589     sflock(F_WRLCK);
590     fseek(syncfp, 0L, 2); /* append index */
591     fprintf(syncfp, "%4d %4d\n", xpos, ypos);
592     fflush(syncfp);
593     /*** Unlock not necessary, since
594     sflock(F_UNLCK); _exit() or nextpiece() is next ***/
595 greg 2.20 }
596 greg 2.25 if (pid == -1) /* didn't fork or fork failed */
597 greg 2.9 return(0);
598 greg 2.25 _exit(0); /* else exit child process (releasing locks) */
599 greg 2.26 }
600    
601    
602 schorsch 2.43 static void
603     filerr( /* report file error and exit */
604     char *t
605     )
606 greg 2.26 {
607     fprintf(stderr, "%s: %s error on file \"%s\": %s\n",
608 greg 2.37 progname, t, outfile, strerror(errno));
609 greg 2.9 _exit(1);
610 greg 2.1 }
611 greg 2.16
612     #endif