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.34 by schorsch, Tue Mar 30 16:13:01 2004 UTC vs.
Revision 2.42 by greg, Wed Dec 15 17:24:29 2010 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"
# Line 34 | 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
# Line 117 | Line 122 | static void sig_alrm(int i) { quit(0); }
122   extern 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;
128                                  /* close input and output descriptors */
129 <        close(fileno(stdin));
130 <        close(fileno(stdout));
129 >        close(0);
130 >        close(1);
131          if (errfile == NULL)
132 <                close(fileno(stderr));
132 >                close(2);
133                                  /* create named pipes for input and output */
134          if (mkfifo(mktemp(strcpy(inpname,TEMPLATE)), 0600) < 0)
135                  goto createrr;
# Line 152 | 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 */
155        /*
156        if (freopen(inpname, "r", stdin) == NULL)
157                goto openerr;
158        if (freopen(outpname, "w", stdout) == NULL)
159                goto openerr;
160        */
160          close(0);
161          if (open(inpname, O_RDONLY) != 0)
162                  error(INTERNAL, "unexpected stdin file number");
# Line 180 | Line 179 | pfhold(void)           /* holding pattern for idle rendering pr
179          return;
180   createrr:
181          error(SYSTEM, "cannot create named pipes in pfhold");
183 openerr:
184        error(SYSTEM, "cannot open named pipes in pfhold");
182   }
183  
184  
# Line 335 | Line 332 | io_process(void)               /* just act as go-between for actual
332                                  } while ((nr -= n) > 0);
333                  }
334          }
335 <        wait(0);                /* wait for feeder process */ /* XXX platform */
335 >        kill(pid, SIGTERM);     /* no more process to feed, so... */
336 >        waitpid(pid, 0, 0);     /* wait for feeder process */
337          _exit(status);
338   formerr:
339          error(USER, "format error in persist file");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines