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.38 by schorsch, Wed Jun 7 17:52:04 2006 UTC vs.
Revision 2.44 by schorsch, Sun Mar 6 01:13:18 2016 UTC

# Line 13 | Line 13 | static const char      RCSid[] = "$Id$";
13   #include <signal.h>
14   #include <sys/stat.h>
15   #include <sys/types.h>
16 #include <sys/wait.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"
# Line 36 | Line 39 | static char    *persistfname = NULL;   /* persist file name
39   static int      persistfd = -1;         /* persist file descriptor */
40   static char     inpname[TEMPLEN+1], outpname[TEMPLEN+1], errname[TEMPLEN+1];
41  
42 < typedef void (sighandler_t)(int);
43 < static sighandler_t sig_io;
44 < static sighandler_t sig_alrm;
42 > typedef void (rsighandler_t)(int);
43 > static rsighandler_t sig_io;
44 > static rsighandler_t sig_alrm;
45  
46  
47 < extern void
47 > void
48   pfdetach(void)          /* release persist (and header) resources */
49   {
50          if (persistfd >= 0)
# Line 55 | Line 58 | pfdetach(void)         /* release persist (and header) resour
58   }
59  
60  
61 < extern void
61 > void
62   pfclean(void)           /* clean up persist files */
63   {
64          if (persistfd >= 0)
# Line 71 | Line 74 | pfclean(void)          /* clean up persist files */
74   }
75  
76  
77 < extern void
77 > void
78   pflock(         /* place or release exclusive lock on file */
79          int     lf
80   )
# Line 87 | Line 90 | pflock(                /* place or release exclusive lock on file */
90   }
91  
92  
93 < extern void
93 > void
94   persistfile(    /* open persist file and lock it */
95          char    *pfn
96   )
# Line 116 | Line 119 | static void sig_io(int i) { got_io++; }
119   static void sig_alrm(int i) { quit(0); }
120  
121  
122 < extern void
122 > void
123   pfhold(void)            /* holding pattern for idle rendering process */
124   {
125 <        sighandler_t    *oldalrm;
125 >        rsighandler_t   *oldalrm;
126          char    buf[512];
127 <        register int    n;
127 >        int     n;
128                                  /* close input and output descriptors */
129          close(0);
130          close(1);
# Line 154 | Line 157 | pfhold(void)           /* holding pattern for idle rendering pr
157          signal(SIGIO, SIG_DFL);
158          pflock(1);                      /* grab persist file back */
159                                  /* someone wants us; reopen stdin and stdout */
157        /*
158        if (freopen(inpname, "r", stdin) == NULL)
159                goto openerr;
160        if (freopen(outpname, "w", stdout) == NULL)
161                goto openerr;
162        */
160          close(0);
161          if (open(inpname, O_RDONLY) != 0)
162                  error(INTERNAL, "unexpected stdin file number");
# Line 182 | Line 179 | pfhold(void)           /* holding pattern for idle rendering pr
179          return;
180   createrr:
181          error(SYSTEM, "cannot create named pipes in pfhold");
185 openerr:
186        error(SYSTEM, "cannot open named pipes in pfhold");
182   }
183  
184  
185 < extern void
185 > void
186   io_process(void)                /* just act as go-between for actual process */
187   {
188 <        register char   *cp;
189 <        register int    nr, n;
188 >        char    *cp;
189 >        int     nr, n;
190          char    buf[BUFSIZ], *pfin, *pfout, *pferr;
191          int     pid, nfds;
192          int     fdout, fderr = -1;
# Line 208 | Line 203 | io_process(void)               /* just act as go-between for actual
203          }
204          if (nr < 0)
205                  error(SYSTEM, "error reading persist file");
211 #ifndef _WIN32 /* XXX we need a replacement for that one */
206          ftruncate(persistfd, (off_t)0L);        /* truncate persist file */
213 #endif
207          pfdetach();                     /* close & release persist file */
208          buf[nr] = '\0';                 /* parse what we got */
209          if ((cp = strchr(buf, ' ')) == NULL)
# Line 302 | Line 295 | io_process(void)               /* just act as go-between for actual
295                                  if (!strncmp(cp, progname, n) &&
296                                                  cp[n++] == ':' &&
297                                                  cp[n++] == ' ') {
298 <                                        register struct erract  *ep;
298 >                                        struct erract   *ep;
299                                          for (ep = erract; ep < erract+NERRS;
300                                                          ep++)
301                                                  if (ep->pre[0] &&
# Line 350 | Line 343 | writerr:
343  
344   #else
345  
346 < extern void pfclean(void) {}
346 > void pfclean(void) {}
347  
348   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines