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.18 by greg, Mon Jul 22 18:09:26 1996 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines