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.12 by greg, Tue Jan 23 15:51:38 1996 UTC vs.
Revision 2.13 by greg, Thu Jul 4 09:54:59 1996 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1995 Regents of the University of California */
1 > /* Copyright (c) 1996 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 75 | Line 75 | int    lf;
75   persistfile(pfn)        /* open persist file and lock it */
76   char    *pfn;
77   {
78 <        persistfd = open(pfn, O_WRONLY|O_CREAT|O_EXCL, 0666);
78 >        persistfd = open(pfn, O_WRONLY|O_CREAT|O_EXCL, 0644);
79          if (persistfd >= 0) {
80                  persistfname = pfn;
81                  pflock(1);
# Line 92 | Line 92 | char   *pfn;
92   }
93  
94  
95 < int sig_noop() {}
95 > static int      got_io;
96  
97 + static int sig_io() { got_io++; }
98  
99 + static int sig_alrm() { quit(0); }
100 +
101 +
102   pfhold()                /* holding pattern for idle rendering process */
103   {
104 +        int     (*oldalrm)();
105          char    buf[512];
106          register int    n;
107                                  /* close input and output descriptors */
# Line 114 | Line 119 | pfhold()               /* holding pattern for idle rendering proces
119          if (write(persistfd, buf, n) < n)
120                  error(SYSTEM, "error writing persist file");
121                                  /* wait TIMELIM for someone to signal us */
122 <        signal(SIGIO, sig_noop);
122 >        got_io = 0;
123 >        signal(SIGIO, sig_io);
124 >        oldalrm = (int (*)())signal(SIGALRM, sig_alrm);
125          alarm(TIMELIM);
126          pflock(0);
127 <        pause();
127 >        while (!got_io)
128 >                pause();
129          alarm(0);
130 +        signal(SIGALRM, oldalrm);
131          signal(SIGIO, SIG_DFL);
132          pflock(1);
133                                  /* someone wants us; reopen stdin and stdout */
# Line 145 | Line 154 | io_process()           /* just act as conduits to and from actu
154          char    buf[512], *pfin, *pfout;
155          int     pid;
156                                  /* load and close persist file */
157 +        sleep(5);               /* helps synchronization */
158          nr = read(persistfd, buf, sizeof(buf)-1);
159          pfdetach();
160 <        if (nr < 0)
160 >        if (nr <= 0)
161                  error(SYSTEM, "cannot read persist file");
162          buf[nr] = '\0';
163          if ((cp = index(buf, ' ')) == NULL)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines