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.21 by gregl, Tue Oct 28 14:00:02 1997 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #ifdef F_SETLKW
14   #include "paths.h"
15 + #include "selcall.h"
16   #include <signal.h>
16 #include <sys/types.h>
17   #include <sys/stat.h>
18                                        /* select call compatibility stuff */
19 #ifndef FD_SETSIZE
20 #include <sys/param.h>
21 #define FD_SETSIZE      NOFILE          /* maximum # select file descriptors */
22 #endif
23 #ifndef FD_SET
24 #ifndef NFDBITS
25 #define NFDBITS         (8*sizeof(int)) /* number of bits per fd_mask */
26 #endif
27 #define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
28 #define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
29 #define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
30 #define FD_ZERO(p)      bzero((char *)(p), sizeof(*(p)))
31 #endif
18  
19   #ifndef TIMELIM
20   #define TIMELIM         (8*3600)        /* time limit for holding pattern */
# Line 140 | Line 126 | pfhold()               /* holding pattern for idle rendering proces
126          n = strlen(buf);
127          if (write(persistfd, buf, n) < n)
128                  error(SYSTEM, "error writing persist file");
129 +        lseek(persistfd, 0L, 0);
130                                  /* wait TIMELIM for someone to signal us */
131          got_io = 0;
132          signal(SIGIO, sig_io);
# Line 148 | Line 135 | pfhold()               /* holding pattern for idle rendering proces
135          pflock(0);                      /* unlock persist file for attach */
136          while (!got_io)
137                  pause();                /* wait for attach */
151        pflock(1);                      /* grab persist file right back! */
138          alarm(0);                       /* turn off alarm */
139          signal(SIGALRM, oldalrm);
140          signal(SIGIO, SIG_DFL);
141 <        if (lseek(persistfd, 0L, 0) < 0 || ftruncate(persistfd, 0L) < 0)
156 <                error(SYSTEM, "seek/truncate error on persist file");
141 >        pflock(1);                      /* grab persist file back */
142                                  /* someone wants us; reopen stdin and stdout */
143          if (freopen(inpname, "r", stdin) == NULL)
144                  goto openerr;
# Line 186 | Line 171 | io_process()           /* just act as go-between for actual pro
171          int     fdin, fdout, fderr = -1;
172          fd_set  readfds, writefds, excepfds;
173                                          /* load persist file */
174 +        n = 40;
175          while ((nr = read(persistfd, buf, sizeof(buf)-1)) == 0) {
176 +                if (!n--)
177 +                        error(USER, "unattended persist file?");
178                  pflock(0);
179                  sleep(15);              /* wait until ready */
180                  pflock(1);
181          }
194        pfdetach();                     /* close persist file */
182          if (nr < 0)
183                  error(SYSTEM, "error reading persist file");
184 <        buf[nr] = '\0';
184 >        ftruncate(persistfd, 0L);       /* truncate persist file */
185 >        pfdetach();                     /* close & release persist file */
186 >        buf[nr] = '\0';                 /* parse what we got */
187          if ((cp = index(buf, ' ')) == NULL)
188                  goto formerr;
189          *cp++ = '\0';
# Line 262 | Line 251 | io_process()           /* just act as go-between for actual pro
251                                  goto readerr;
252                          if (nr == 0) {
253                                  close(fderr);
254 <                                close(2);
254 >                                /* close(2);    don't close stderr! */
255                                  fderr = -1;
256                          } else
257                                  do {            /* write it all */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines