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

Comparing ray/src/rt/persist.c (file contents):
Revision 2.16 by greg, Mon Jul 8 19:46:21 1996 UTC vs.
Revision 2.19 by gregl, Thu Sep 18 16:13:28 1997 UTC

# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ LBL";
14   #include "paths.h"
15   #include <signal.h>
16   #include <sys/types.h>
17 + #include <sys/select.h>
18   #include <sys/stat.h>
19                                          /* select call compatibility stuff */
20   #ifndef FD_SETSIZE
# Line 140 | Line 141 | pfhold()               /* holding pattern for idle rendering proces
141          n = strlen(buf);
142          if (write(persistfd, buf, n) < n)
143                  error(SYSTEM, "error writing persist file");
144 +        lseek(persistfd, 0L, 0);
145                                  /* wait TIMELIM for someone to signal us */
146          got_io = 0;
147          signal(SIGIO, sig_io);
# Line 148 | Line 150 | pfhold()               /* holding pattern for idle rendering proces
150          pflock(0);                      /* unlock persist file for attach */
151          while (!got_io)
152                  pause();                /* wait for attach */
151        pflock(1);                      /* grab persist file right back! */
153          alarm(0);                       /* turn off alarm */
154          signal(SIGALRM, oldalrm);
155          signal(SIGIO, SIG_DFL);
156 <        if (lseek(persistfd, 0L, 0) < 0 || ftruncate(persistfd, 0L) < 0)
156 <                error(SYSTEM, "seek/truncate error on persist file");
156 >        pflock(1);                      /* grab persist file back */
157                                  /* someone wants us; reopen stdin and stdout */
158          if (freopen(inpname, "r", stdin) == NULL)
159                  goto openerr;
# Line 186 | Line 186 | io_process()           /* just act as go-between for actual pro
186          int     fdin, fdout, fderr = -1;
187          fd_set  readfds, writefds, excepfds;
188                                          /* load persist file */
189 +        n = 40;
190          while ((nr = read(persistfd, buf, sizeof(buf)-1)) == 0) {
191 +                if (!n--)
192 +                        error(USER, "unattended persist file?");
193                  pflock(0);
194                  sleep(15);              /* wait until ready */
195                  pflock(1);
196          }
194        pfdetach();                     /* close persist file */
197          if (nr < 0)
198                  error(SYSTEM, "error reading persist file");
199 <        buf[nr] = '\0';
199 >        ftruncate(persistfd, 0L);       /* truncate persist file */
200 >        pfdetach();                     /* close & release persist file */
201 >        buf[nr] = '\0';                 /* parse what we got */
202          if ((cp = index(buf, ' ')) == NULL)
203                  goto formerr;
204          *cp++ = '\0';
# Line 262 | Line 266 | io_process()           /* just act as go-between for actual pro
266                                  goto readerr;
267                          if (nr == 0) {
268                                  close(fderr);
269 <                                close(2);
269 >                                /* close(2);    don't close stderr! */
270                                  fderr = -1;
271                          } else
272                                  do {            /* write it all */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines