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.8 by greg, Wed Mar 3 09:07:52 1993 UTC vs.
Revision 2.11 by greg, Mon Nov 8 09:35:32 1993 UTC

# Line 101 | Line 101 | pfhold()               /* holding pattern for idle rendering proces
101          close(fileno(stdin));
102          close(fileno(stdout));
103                                  /* create named pipes for input and output */
104 <        if (mknod(mktemp(strcpy(inpname,TEMPLATE)), S_IFIFO|0600) < 0)
104 >        if (mknod(mktemp(strcpy(inpname,TEMPLATE)), S_IFIFO|0600, 0) < 0)
105                  goto createrr;
106 <        if (mknod(mktemp(strcpy(outpname,TEMPLATE)), S_IFIFO|0600) < 0)
106 >        if (mknod(mktemp(strcpy(outpname,TEMPLATE)), S_IFIFO|0600, 0) < 0)
107                  goto createrr;
108          sprintf(buf, "%d\n%s\n%s\n", getpid(), inpname, outpname);
109 <        if (lseek(persistfd, 0L, 0) < 0)
110 <                error(SYSTEM, "seek error on persist file in pfhold");
109 >        if (lseek(persistfd, 0L, 0) < 0 || ftruncate(persistfd, 0L) < 0)
110 >                error(SYSTEM, "seek/truncate error on persist file");
111          n = strlen(buf);
112          if (write(persistfd, buf, n) < n)
113 <                error(SYSTEM, "error writing persist file in pfhold");
113 >                error(SYSTEM, "error writing persist file");
114                                  /* wait TIMELIM for someone to signal us */
115          signal(SIGIO, sig_noop);
116          alarm(TIMELIM);
# Line 180 | Line 180 | io_process()           /* just act as conduits to and from actu
180                          error(SYSTEM, "cannot open output pipe in io_process");
181          }
182                                  /* pass input to output */
183 <        cp = buf; n = sizeof(buf);
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(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 <        }
183 >                                /* read as much as we can, write all of it */
184 >        while ((nr = read(0, cp=buf, sizeof(buf))) > 0)
185 >                do {
186 >                        if ((n = write(1, cp, nr)) <= 0)
187 >                                goto writerr;
188 >                        cp += n;
189 >                } while ((nr -= n) > 0);
190          if (nr < 0)
191                  error(SYSTEM, "read error in io_process");
192          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        }
193          close(1);               /* close output */
194          if (pid)                /* parent waits for child */
195                  wait(0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines