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

Comparing ray/src/common/unix_process.c (file contents):
Revision 3.4 by greg, Tue Nov 11 16:24:06 2003 UTC vs.
Revision 3.6 by greg, Sun Sep 19 08:42:22 2004 UTC

# Line 12 | Line 12 | static const char      RCSid[] = "$Id$";
12  
13   #include <sys/types.h>
14   #include <sys/wait.h>
15 + #include <fcntl.h>
16  
17   #include "rtprocess.h"
18  
# Line 54 | Line 55 | char   *av[]
55          close(p1[1]);
56          pd->r = p1[0];
57          pd->w = p0[1];
58 +        /*
59 +         * Close write stream on exec to avoid multiprocessing deadlock.
60 +         * No use in read stream without it, so set flag there as well.
61 +         * GW: This bug took me two days to figure out!!
62 +         */
63 +        fcntl(pd->r, F_SETFD, FD_CLOEXEC);
64 +        fcntl(pd->w, F_SETFD, FD_CLOEXEC);
65          pd->running = 1;
66          return(PIPE_BUF);
67   }
# Line 67 | Line 75 | SUBPROC *pd
75   {
76          int     pid, status;
77  
78 +        if (!pd->running)
79 +                return(0);
80          close(pd->r);
81          close(pd->w);
82          pd->running = 0;
83 <        while ((pid = wait(&status)) != -1)
84 <                if (pid == pd->pid)
75 <                        return(status>>8 & 0xff);
83 >        if (waitpid(pd->pid, &status, 0) == pd->pid)
84 >                return(status>>8 & 0xff);
85          return(-1);             /* ? unknown status */
86   }
87  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines