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

Comparing ray/src/util/rpiece.c (file contents):
Revision 2.5 by greg, Fri Aug 7 11:05:30 1992 UTC vs.
Revision 2.7 by greg, Sat Aug 8 18:47:39 1992 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10  
11   #include "standard.h"
12   #include <fcntl.h>
13 + #include <signal.h>
14   #include "color.h"
15   #include "view.h"
16   #include "resolu.h"
# Line 35 | Line 36 | int  verbose = 0;
36  
37   extern long  lseek(), ftell();
38  
39 + int  gotalrm = 0;
40 + int  onalrm() { gotalrm++; }
41  
42 +
43   main(argc, argv)
44   int  argc;
45   char  *argv[];
# Line 168 | Line 172 | char  **av;
172          scanorig = ftell(fp);           /* record position of first scanline */
173          if (fclose(fp) == -1)           /* done with stream i/o */
174                  goto filerr;
171        sync();                         /* avoid NFS buffering */
175                                          /* start rpict process */
176          if (open_process(rpd, rpargv) <= 0) {
177                  fprintf(stderr, "%s: cannot start %s\n", progname, rpargv[0]);
# Line 184 | Line 187 | char  **av;
187                  fprintf(stderr, "%s: out of memory\n", progname);
188                  exit(1);
189          }
190 +        signal(SIGALRM, onalrm);
191          return;
192   filerr:
193          fprintf(stderr, "%s: file i/o error\n", outfile);
# Line 199 | Line 203 | int  *xp, *yp;
203          struct flock  fls;
204          char  buf[64];
205  
206 <        if (syncfd != -1) {             /* using sync file */
206 >        if (gotalrm)                    /* someone wants us to quit */
207 >                return(0);
208 >        if (syncfd != -1) {             /* use sync file */
209                  fls.l_type = F_WRLCK;           /* gain exclusive access */
210                  fls.l_whence = 0;
211                  fls.l_start = 0L;
# Line 225 | Line 231 | int  *xp, *yp;
231                  fcntl(syncfd, F_SETLKW, &fls);
232                  return(1);
233          }
234 <        if (fgets(buf, sizeof(buf), stdin) == NULL)     /* using stdin */
234 >        if (fgets(buf, sizeof(buf), stdin) == NULL)     /* use stdin */
235                  return(0);
236          if (sscanf(buf, "%d %d", xp, yp) == 2)
237                  return(1);
# Line 297 | Line 303 | rpiece()                       /* render picture piece by piece */
303   putpiece(xpos, ypos)            /* get next piece from rpict */
304   int  xpos, ypos;
305   {
306 +        struct flock  fls;
307          int  hr, vr;
308          int  y;
309  
# Line 312 | Line 319 | int  xpos, ypos;
319                                  progname, rpargv[0]);
320                  exit(1);
321          }
322 +        fls.l_whence = 1;
323 +        fls.l_start = 0L;
324 +        fls.l_len = hr*sizeof(COLR);
325          for (y = 0; y < vr; y++) {      /* transfer scanlines */
326                  if (freadcolrs(scanline, hr, fromrp) < 0) {
327                          fprintf(stderr, "%s: read error from %s\n",
# Line 324 | Line 334 | scanorig+((long)((vmult-1-ypos)*vres+y)*hmult*hres+xpo
334                          fprintf(stderr, "%s: seek error\n", outfile);
335                          exit(1);
336                  }
337 +                fls.l_type = F_WRLCK;
338 +                fcntl(outfd, F_SETLKW, &fls);
339                  if (writebuf(outfd, (char *)scanline, hr*sizeof(COLR)) !=
340                                  hr*sizeof(COLR)) {
341                          fprintf(stderr, "%s: write error\n", outfile);
342                          exit(1);
343                  }
344 +                fls.l_type = F_UNLCK;
345 +                fcntl(outfd, F_SETLKW, &fls);
346          }
347   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines