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.36 by greg, Sun Sep 19 07:24:37 2004 UTC vs.
Revision 2.45 by greg, Sat Jun 7 05:09:46 2025 UTC

# Line 12 | Line 12 | static const char      RCSid[] = "$Id$";
12   #include <string.h>
13   #include <signal.h>
14   #include <sys/stat.h>
15 + #include <sys/types.h>
16  
17   #include "platform.h"
18 + #ifndef NON_POSIX /* XXX need abstraction for process management */
19 + #include <sys/wait.h>
20 + #endif
21 +
22   #include "rtprocess.h" /* getpid() */
23   #include "standard.h"
24   #include "random.h"
25   #include "ray.h"
26  
27   #ifdef F_SETLKW
23 #include "paths.h"
28   #include "selcall.h"
29  
30   #ifndef TIMELIM
# Line 34 | Line 38 | static char    *persistfname = NULL;   /* persist file name
38   static int      persistfd = -1;         /* persist file descriptor */
39   static char     inpname[TEMPLEN+1], outpname[TEMPLEN+1], errname[TEMPLEN+1];
40  
41 < typedef void (sighandler_t)(int);
42 < static sighandler_t sig_io;
43 < static sighandler_t sig_alrm;
41 > typedef void (rsighandler_t)(int);
42 > static rsighandler_t sig_io;
43 > static rsighandler_t sig_alrm;
44  
45  
46 < extern void
46 > void
47   pfdetach(void)          /* release persist (and header) resources */
48   {
49          if (persistfd >= 0)
# Line 53 | Line 57 | pfdetach(void)         /* release persist (and header) resour
57   }
58  
59  
60 < extern void
60 > void
61   pfclean(void)           /* clean up persist files */
62   {
63          if (persistfd >= 0)
# Line 69 | Line 73 | pfclean(void)          /* clean up persist files */
73   }
74  
75  
76 < extern void
76 > void
77   pflock(         /* place or release exclusive lock on file */
78          int     lf
79   )
# Line 85 | Line 89 | pflock(                /* place or release exclusive lock on file */
89   }
90  
91  
92 < extern void
92 > void
93   persistfile(    /* open persist file and lock it */
94          char    *pfn
95   )
# Line 114 | Line 118 | static void sig_io(int i) { got_io++; }
118   static void sig_alrm(int i) { quit(0); }
119  
120  
121 < extern void
121 > void
122   pfhold(void)            /* holding pattern for idle rendering process */
123   {
124 <        sighandler_t    *oldalrm;
124 >        rsighandler_t   *oldalrm;
125          char    buf[512];
126 <        register int    n;
126 >        int     n;
127                                  /* close input and output descriptors */
128 <        close(fileno(stdin));
129 <        close(fileno(stdout));
128 >        close(0);
129 >        close(1);
130          if (errfile == NULL)
131 <                close(fileno(stderr));
131 >                close(2);
132                                  /* create named pipes for input and output */
133          if (mkfifo(mktemp(strcpy(inpname,TEMPLATE)), 0600) < 0)
134                  goto createrr;
# Line 152 | Line 156 | pfhold(void)           /* holding pattern for idle rendering pr
156          signal(SIGIO, SIG_DFL);
157          pflock(1);                      /* grab persist file back */
158                                  /* someone wants us; reopen stdin and stdout */
155        /*
156        if (freopen(inpname, "r", stdin) == NULL)
157                goto openerr;
158        if (freopen(outpname, "w", stdout) == NULL)
159                goto openerr;
160        */
159          close(0);
160          if (open(inpname, O_RDONLY) != 0)
161                  error(INTERNAL, "unexpected stdin file number");
# Line 180 | Line 178 | pfhold(void)           /* holding pattern for idle rendering pr
178          return;
179   createrr:
180          error(SYSTEM, "cannot create named pipes in pfhold");
183 openerr:
184        error(SYSTEM, "cannot open named pipes in pfhold");
181   }
182  
183  
184 < extern void
184 > void
185   io_process(void)                /* just act as go-between for actual process */
186   {
187 <        register char   *cp;
188 <        register int    nr, n;
187 >        char    *cp;
188 >        int     nr, n;
189          char    buf[BUFSIZ], *pfin, *pfout, *pferr;
190          int     pid, nfds;
191          int     fdout, fderr = -1;
# Line 206 | Line 202 | io_process(void)               /* just act as go-between for actual
202          }
203          if (nr < 0)
204                  error(SYSTEM, "error reading persist file");
209 #ifndef _WIN32 /* XXX we need a replacement for that one */
205          ftruncate(persistfd, (off_t)0L);        /* truncate persist file */
211 #endif
206          pfdetach();                     /* close & release persist file */
207          buf[nr] = '\0';                 /* parse what we got */
208          if ((cp = strchr(buf, ' ')) == NULL)
# Line 300 | Line 294 | io_process(void)               /* just act as go-between for actual
294                                  if (!strncmp(cp, progname, n) &&
295                                                  cp[n++] == ':' &&
296                                                  cp[n++] == ' ') {
297 <                                        register struct erract  *ep;
297 >                                        struct erract   *ep;
298                                          for (ep = erract; ep < erract+NERRS;
299                                                          ep++)
300                                                  if (ep->pre[0] &&
# Line 348 | Line 342 | writerr:
342  
343   #else
344  
345 < extern void pfclean(void) {}
345 > void pfclean(void) {}
346  
347   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines