--- ray/src/rt/persist.c 1997/11/07 12:12:53 2.22 +++ ray/src/rt/persist.c 1998/01/03 20:07:31 2.25 @@ -1,7 +1,7 @@ -/* Copyright (c) 1996 Regents of the University of California */ +/* Copyright (c) 1997 Silicon Graphics, Inc. */ #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static char SCCSid[] = "$SunId$ SGI"; #endif /* @@ -9,6 +9,7 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include "standard.h" +#include "random.h" #ifdef F_SETLKW #include "paths.h" @@ -170,6 +171,7 @@ io_process() /* just act as go-between for actual pro char buf[BUFSIZ], *pfin, *pfout, *pferr; int pid, nfds; int fdout, fderr = -1; + int status = 0; fd_set readfds, excepfds; /* load persist file */ n = 40; @@ -177,7 +179,7 @@ io_process() /* just act as go-between for actual pro if (!n--) error(USER, "unattended persist file?"); pflock(0); - sleep(15); /* wait until ready */ + sleep(3+(3*getpid()+random())%13); /* wait until ready */ pflock(1); } if (nr < 0) @@ -268,12 +270,28 @@ io_process() /* just act as go-between for actual pro close(fderr); /* close(2); don't close stderr! */ fderr = -1; - } else - do { /* write it all */ + } else { + cp[nr] = '\0'; /* deduce status if we can */ + n = strlen(progname); + if (!strncmp(cp, progname, n) && + cp[n++] == ':' && + cp[n++] == ' ') { + register struct erract *ep; + for (ep = erract; ep < erract+NERRS; + ep++) + if (ep->pre[0] && + !strncmp(cp+n, ep->pre, + strlen(ep->pre))) { + status = ep->ec; + break; + } + } + do { /* write message */ if ((n = write(2, cp, nr)) <= 0) goto writerr; cp += n; } while ((nr -= n) > 0); + } } /* renderer stdout */ if (fdout >= 0 && (FD_ISSET(fdout, &readfds) || @@ -293,7 +311,8 @@ io_process() /* just act as go-between for actual pro } while ((nr -= n) > 0); } } - _exit(0); /* we ought to return renderer error status! */ + wait(0); /* wait for feeder process */ + _exit(status); formerr: error(USER, "format error in persist file"); readerr: