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.9 by greg, Sun Aug 9 13:31:30 1992 UTC vs.
Revision 2.10 by greg, Sun Aug 9 18:09:46 1992 UTC

# Line 17 | Line 17 | static char SCCSid[] = "$SunId$ LBL";
17  
18                                  /* set the following to 0 to forgo forking */
19   #ifndef MAXFORK
20 < #define  MAXFORK                2       /* max. unreaped child processes */
20 > #define  MAXFORK                3       /* allotment of duped processes */
21   #endif
22  
23                                  /* rpict command */
# Line 123 | Line 123 | char  *argv[];
123          }
124          init(argc, argv);
125          rpiece();
126 <        rval = cleanup();
126 >        rval = cleanup(0);
127          exit(rval);
128   }
129  
# Line 244 | Line 244 | int  *xp, *yp;
244          if (sscanf(buf, "%d %d", xp, yp) == 2)
245                  return(1);
246          fprintf(stderr, "%s: input format error\n", progname);
247 <        exit(1);
247 >        exit(cleanup(1));
248   }
249  
250  
251   int
252 < cleanup()                       /* close rpict process and clean up */
252 > cleanup(rstat)                  /* close rpict process and clean up */
253 > int  rstat;
254   {
255 <        register int  pid;
255 <        int  status, rstat = 0;
255 >        int  status;
256  
257          free((char *)pbuf);
258          fclose(torp);
259          fclose(fromrp);
260 <        while ((pid = wait(&status)) != -1)
260 >        while (wait(&status) != -1)
261                  if (rstat == 0)
262                          rstat = status>>8 & 0xff;
263          return(rstat);
# Line 292 | Line 292 | rpiece()                       /* render picture piece by piece */
292                  default:
293                          fprintf(stderr, "%s: unknown view type '-vt%c'\n",
294                                          progname, ourview.type);
295 <                        exit(1);
295 >                        exit(cleanup(1));
296                  }
297                  pview.hoff += xorg - 0.5*(hmult-1);
298                  pview.voff += yorg - 0.5*(vmult-1);
# Line 321 | Line 321 | int  xpos, ypos;
321          if (xpos < 0 | ypos < 0 | xpos >= hmult | ypos >= vmult) {
322                  fprintf(stderr, "%s: requested piece (%d,%d) out of range\n",
323                                  progname, xpos, ypos);
324 <                exit(1);
324 >                exit(cleanup(1));
325          }
326                                  /* check header from rpict */
327          getheader(fromrp, NULL);
328          if (fscnresolu(&hr, &vr, fromrp) < 0 || hr != hres || vr != vres) {
329                  fprintf(stderr, "%s: resolution mismatch from %s\n",
330                                  progname, rpargv[0]);
331 <                exit(1);
331 >                exit(cleanup(1));
332          }
333                                  /* load new piece into buffer */
334          for (y = 0; y < vr; y++)
335                  if (freadcolrs(pbuf+y*hr, hr, fromrp) < 0) {
336                          fprintf(stderr, "%s: read error from %s\n",
337                                          progname, rpargv[0]);
338 <                        exit(1);
338 >                        exit(cleanup(1));
339                  }
340   #if MAXFORK
341                                  /* fork so we don't slow rpict down */
342          if ((pid = fork()) > 0) {
343 <                if (++nforked > MAXFORK) {
343 >                if (++nforked >= MAXFORK) {
344                          wait(&status);          /* reap a child */
345                          if (status)
346 <                                exit(status>>8 & 0xff);
346 >                                exit(cleanup(status>>8 & 0xff));
347                          nforked--;
348                  }
349                  return(pid);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines