--- ray/src/rt/persist.c 1993/03/03 09:07:52 2.8 +++ ray/src/rt/persist.c 1993/11/08 09:35:32 2.11 @@ -101,16 +101,16 @@ pfhold() /* holding pattern for idle rendering proces close(fileno(stdin)); close(fileno(stdout)); /* create named pipes for input and output */ - if (mknod(mktemp(strcpy(inpname,TEMPLATE)), S_IFIFO|0600) < 0) + if (mknod(mktemp(strcpy(inpname,TEMPLATE)), S_IFIFO|0600, 0) < 0) goto createrr; - if (mknod(mktemp(strcpy(outpname,TEMPLATE)), S_IFIFO|0600) < 0) + if (mknod(mktemp(strcpy(outpname,TEMPLATE)), S_IFIFO|0600, 0) < 0) goto createrr; sprintf(buf, "%d\n%s\n%s\n", getpid(), inpname, outpname); - if (lseek(persistfd, 0L, 0) < 0) - error(SYSTEM, "seek error on persist file in pfhold"); + if (lseek(persistfd, 0L, 0) < 0 || ftruncate(persistfd, 0L) < 0) + error(SYSTEM, "seek/truncate error on persist file"); n = strlen(buf); if (write(persistfd, buf, n) < n) - error(SYSTEM, "error writing persist file in pfhold"); + error(SYSTEM, "error writing persist file"); /* wait TIMELIM for someone to signal us */ signal(SIGIO, sig_noop); alarm(TIMELIM); @@ -180,28 +180,16 @@ io_process() /* just act as conduits to and from actu error(SYSTEM, "cannot open output pipe in io_process"); } /* pass input to output */ - cp = buf; n = sizeof(buf); - /* do as much as we can each way */ - while ((nr = read(0, cp, n)) > 0) { - nr += cp-buf; - if ((n = write(1, buf, nr)) <= 0) - goto writerr; - cp = buf; - while (n < nr) - *cp++ = buf[n++]; - n = sizeof(buf) - (cp-buf); - } + /* read as much as we can, write all of it */ + while ((nr = read(0, cp=buf, sizeof(buf))) > 0) + do { + if ((n = write(1, cp, nr)) <= 0) + goto writerr; + cp += n; + } while ((nr -= n) > 0); if (nr < 0) error(SYSTEM, "read error in io_process"); close(0); /* close input */ - nr = cp-buf; /* write remainder */ - cp = buf; - while (nr > 0) { - if ((n = write(1, cp, nr)) <= 0) - goto writerr; - cp += n; - nr -= n; - } close(1); /* close output */ if (pid) /* parent waits for child */ wait(0);