ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/persist.c
(Generate patch)

Comparing ray/src/rt/persist.c (file contents):
Revision 2.11 by greg, Mon Nov 8 09:35:32 1993 UTC vs.
Revision 2.12 by greg, Tue Jan 23 15:51:38 1996 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1993 Regents of the University of California */
1 > /* Copyright (c) 1995 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 25 | Line 25 | extern char    *strcpy(), *index();
25  
26   extern int      headismine;     /* boolean true if header belongs to me */
27  
28 + extern char     *progname;      /* global program name */
29 +
30   static char     *persistfname = NULL;   /* persist file name */
31   static int      persistfd = -1;         /* persist file descriptor */
32  
# Line 95 | Line 97 | int sig_noop() {}
97  
98   pfhold()                /* holding pattern for idle rendering process */
99   {
100 <        char    buf[128];
100 >        char    buf[512];
101          register int    n;
102                                  /* close input and output descriptors */
103          close(fileno(stdin));
# Line 105 | Line 107 | pfhold()               /* holding pattern for idle rendering proces
107                  goto createrr;
108          if (mknod(mktemp(strcpy(outpname,TEMPLATE)), S_IFIFO|0600, 0) < 0)
109                  goto createrr;
110 <        sprintf(buf, "%d\n%s\n%s\n", getpid(), inpname, outpname);
110 >        sprintf(buf, "%s %d\n%s\n%s\n", progname, getpid(), inpname, outpname);
111          if (lseek(persistfd, 0L, 0) < 0 || ftruncate(persistfd, 0L) < 0)
112                  error(SYSTEM, "seek/truncate error on persist file");
113          n = strlen(buf);
# Line 140 | Line 142 | io_process()           /* just act as conduits to and from actu
142   {
143          register char   *cp;
144          register int    nr, n;
145 <        char    buf[4096], *pfin, *pfout;
145 >        char    buf[512], *pfin, *pfout;
146          int     pid;
147                                  /* load and close persist file */
148 <        nr = read(persistfd, buf, sizeof(buf));
148 >        nr = read(persistfd, buf, sizeof(buf)-1);
149          pfdetach();
150          if (nr < 0)
151                  error(SYSTEM, "cannot read persist file");
152          buf[nr] = '\0';
153 <        if ((cp = index(buf, '\n')) == NULL)
153 >        if ((cp = index(buf, ' ')) == NULL)
154                  goto formerr;
155          *cp++ = '\0';
156 <        if ((pid = atoi(buf)) <= 0)
156 >        if ((pid = atoi(cp)) <= 0)
157                  goto formerr;
156        pfin = cp;
158          if ((cp = index(cp, '\n')) == NULL)
159                  goto formerr;
160 +        pfin = ++cp;
161 +        if ((cp = index(cp, '\n')) == NULL)
162 +                goto formerr;
163          *cp++ = '\0';
164          pfout = cp;
165          if ((cp = index(cp, '\n')) == NULL)
# Line 163 | Line 167 | io_process()           /* just act as conduits to and from actu
167          *cp++ = '\0';
168          if (cp-buf != nr)
169                  goto formerr;
170 +        if (strcmp(buf, progname)) {
171 +                sprintf(errmsg, "persist file for %s, not %s", buf, progname);
172 +                error(USER, errmsg);
173 +        }
174                                  /* wake up rendering process */
175          if (kill(pid, SIGIO) < 0)
176                  error(SYSTEM, "cannot signal rendering process in io_process");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines