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.2 by greg, Thu Jan 21 10:09:04 1993 UTC vs.
Revision 2.7 by greg, Wed Feb 10 11:02:20 1993 UTC

# Line 9 | Line 9 | static char SCCSid[] = "$SunId$ LBL";
9   */
10  
11   #include "standard.h"
12 +
13 + #ifdef F_SETLKW
14 +
15   #include "paths.h"
16   #include <signal.h>
17   #include <sys/types.h>
# Line 96 | Line 99 | pfhold()               /* holding pattern for idle rendering proces
99          register int    n;
100                                  /* close input and output descriptors */
101          close(fileno(stdin));
99        fflush(stdout);
102          close(fileno(stdout));
103                                  /* create named pipes for input and output */
104          if (mknod(mktemp(strcpy(inpname,TEMPLATE)), S_IFIFO|0600) < 0)
# Line 169 | Line 171 | io_process()           /* just act as conduits to and from actu
171                  error(SYSTEM, "fork failed in io_process");
172                                  /* connect to appropriate pipe */
173          if (pid) {                      /* parent passes renderer output */
174 <                if (freopen(pfout, "r", stdin) == NULL)
174 >                close(0);
175 >                if (open(pfout, O_RDONLY) != 0)
176                          error(SYSTEM, "cannot open input pipe in io_process");
177          } else {                        /* child passes renderer input */
178 <                if (freopen(pfin, "w", stdout) == NULL)
179 <                        error(SYSTEM, "cannot open input pipe in io_process");
178 >                close(1);
179 >                if (open(pfin, O_WRONLY) != 1)
180 >                        error(SYSTEM, "cannot open output pipe in io_process");
181          }
182                                  /* pass input to output */
183          cp = buf; n = sizeof(buf);
184 <        while ((nr = read(fileno(stdin), cp, n)) > 0) {
184 >                                /* do as much as we can each way */
185 >        while ((nr = read(0, cp, n)) > 0) {
186                  nr += cp-buf;
187 <                if ((n = write(fileno(stdout), buf, nr)) <= 0)
188 <                        error(SYSTEM, "write error in io_process");
187 >                if ((n = write(1, buf, nr)) <= 0)
188 >                        goto writerr;
189                  cp = buf;
190                  while (n < nr)
191                          *cp++ = buf[n++];
192                  n = sizeof(buf) - (cp-buf);
193          }
194 <        fclose(stdin);
195 <        fclose(stdout);
194 >        if (nr < 0)
195 >                error(SYSTEM, "read error in io_process");
196 >        close(0);               /* close input */
197 >        nr = cp-buf;            /* write remainder */
198 >        cp = buf;
199 >        while (nr > 0) {
200 >                if ((n = write(1, cp, nr)) <= 0)
201 >                        goto writerr;
202 >                cp += n;
203 >                nr -= n;
204 >        }
205 >        close(1);               /* close output */
206          if (pid)                /* parent waits for child */
207                  wait(0);
208          exit(0);                /* all done, exit (not quit!) */
209   formerr:
210          error(USER, "format error in persist file");
211 + writerr:
212 +        error(SYSTEM, "write error in io_process");
213   }
214 +
215 + #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines