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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines