--- ray/src/rt/persist.c 2003/02/25 02:47:23 2.27 +++ ray/src/rt/persist.c 2003/10/20 16:01:55 2.32 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: persist.c,v 2.27 2003/02/25 02:47:23 greg Exp $"; +static const char RCSid[] = "$Id: persist.c,v 2.32 2003/10/20 16:01:55 greg Exp $"; #endif /* * Routines for persistent rtrace and rpict processes. @@ -9,23 +9,23 @@ static const char RCSid[] = "$Id: persist.c,v 2.27 200 #include "copyright.h" +#include +#include +#include + +#include "rtprocess.h" /* getpid() */ #include "standard.h" +#include "platform.h" #include "random.h" #ifdef F_SETLKW #include "paths.h" #include "selcall.h" -#include -#include #ifndef TIMELIM #define TIMELIM (8*3600) /* time limit for holding pattern */ #endif -#ifndef freebsd -#define mkfifo(fn,md) mknod(fn, S_IFIFO|(md), 0) -#endif - extern void io_process(); extern int headismine; /* boolean true if header belongs to me */ @@ -85,6 +85,7 @@ int lf; } +void persistfile(pfn) /* open persist file and lock it */ char *pfn; { @@ -136,7 +137,7 @@ pfhold() /* holding pattern for idle rendering proces n = strlen(buf); if (write(persistfd, buf, n) < n) error(SYSTEM, "error writing persist file"); - lseek(persistfd, (off_t)0L, 0); + lseek(persistfd, (off_t)0, SEEK_SET); /* wait TIMELIM for someone to signal us */ got_io = 0; signal(SIGIO, sig_io); @@ -204,26 +205,28 @@ io_process() /* just act as go-between for actual pro } if (nr < 0) error(SYSTEM, "error reading persist file"); +#ifndef _WIN32 /* XXX we need a replacement for that one */ ftruncate(persistfd, (off_t)0L); /* truncate persist file */ +#endif pfdetach(); /* close & release persist file */ buf[nr] = '\0'; /* parse what we got */ - if ((cp = index(buf, ' ')) == NULL) + if ((cp = strchr(buf, ' ')) == NULL) goto formerr; *cp++ = '\0'; if ((pid = atoi(cp)) <= 0) goto formerr; - if ((cp = index(cp, '\n')) == NULL) + if ((cp = strchr(cp, '\n')) == NULL) goto formerr; pfin = ++cp; - if ((cp = index(cp, '\n')) == NULL) + if ((cp = strchr(cp, '\n')) == NULL) goto formerr; *cp++ = '\0'; pfout = cp; - if ((cp = index(cp, '\n')) == NULL) + if ((cp = strchr(cp, '\n')) == NULL) goto formerr; *cp++ = '\0'; pferr = cp; - if ((cp = index(cp, '\n')) == NULL) + if ((cp = strchr(cp, '\n')) == NULL) goto formerr; *cp++ = '\0'; if (cp-buf != nr)