--- ray/src/rt/persist.c 2004/09/17 21:43:50 2.35 +++ ray/src/rt/persist.c 2008/05/01 15:50:28 2.41 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: persist.c,v 2.35 2004/09/17 21:43:50 greg Exp $"; +static const char RCSid[] = "$Id: persist.c,v 2.41 2008/05/01 15:50:28 greg Exp $"; #endif /* * Routines for persistent rtrace and rpict processes. @@ -12,8 +12,13 @@ static const char RCSid[] = "$Id: persist.c,v 2.35 200 #include #include #include +#include #include "platform.h" +#ifndef NON_POSIX /* XXX need abstraction for process management */ + #include +#endif + #include "rtprocess.h" /* getpid() */ #include "standard.h" #include "random.h" @@ -121,10 +126,10 @@ pfhold(void) /* holding pattern for idle rendering pr char buf[512]; register int n; /* close input and output descriptors */ - close(fileno(stdin)); - close(fileno(stdout)); + close(0); + close(1); if (errfile == NULL) - close(fileno(stderr)); + close(2); /* create named pipes for input and output */ if (mkfifo(mktemp(strcpy(inpname,TEMPLATE)), 0600) < 0) goto createrr; @@ -152,12 +157,6 @@ pfhold(void) /* holding pattern for idle rendering pr signal(SIGIO, SIG_DFL); pflock(1); /* grab persist file back */ /* someone wants us; reopen stdin and stdout */ - /* - if (freopen(inpname, "r", stdin) == NULL) - goto openerr; - if (freopen(outpname, "w", stdout) == NULL) - goto openerr; - */ close(0); if (open(inpname, O_RDONLY) != 0) error(INTERNAL, "unexpected stdin file number"); @@ -180,8 +179,6 @@ pfhold(void) /* holding pattern for idle rendering pr return; createrr: error(SYSTEM, "cannot create named pipes in pfhold"); -openerr: - error(SYSTEM, "cannot open named pipes in pfhold"); } @@ -335,6 +332,7 @@ io_process(void) /* just act as go-between for actual } while ((nr -= n) > 0); } } + kill(pid, SIGTERM); /* no more process to feed, so... */ waitpid(pid, 0, 0); /* wait for feeder process */ _exit(status); formerr: