--- ray/src/rt/persist.c 1993/01/25 19:17:36 2.5 +++ ray/src/rt/persist.c 1993/04/01 08:55:37 2.9 @@ -9,6 +9,9 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include "standard.h" + +#ifdef F_SETLKW + #include "paths.h" #include #include @@ -168,28 +171,37 @@ io_process() /* just act as conduits to and from actu error(SYSTEM, "fork failed in io_process"); /* connect to appropriate pipe */ if (pid) { /* parent passes renderer output */ - if (freopen(pfout, "r", stdin) == NULL) + close(0); + if (open(pfout, O_RDONLY) != 0) error(SYSTEM, "cannot open input pipe in io_process"); } else { /* child passes renderer input */ - if (freopen(pfin, "w", stdout) == NULL) - error(SYSTEM, "cannot open input pipe in io_process"); + close(1); + if (open(pfin, O_WRONLY) != 1) + error(SYSTEM, "cannot open output pipe in io_process"); } /* pass input to output */ - cp = buf; n = sizeof(buf); - while ((nr = read(fileno(stdin), cp, n)) > 0) { - nr += cp-buf; - if ((n = write(fileno(stdout), buf, nr)) <= 0) - error(SYSTEM, "write error in io_process"); - cp = buf; - while (n < nr) - *cp++ = buf[n++]; - n = sizeof(buf) - (cp-buf); - } - fclose(stdin); - fclose(stdout); + /* 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 */ + close(1); /* close output */ if (pid) /* parent waits for child */ wait(0); exit(0); /* all done, exit (not quit!) */ formerr: error(USER, "format error in persist file"); +writerr: + error(SYSTEM, "write error in io_process"); } + +#else + +pfclean() {} + +#endif