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.11 by greg, Fri Mar 4 02:48:14 2016 UTC vs.
Revision 3.14 by greg, Tue May 14 18:37:36 2019 UTC

# Line 28 | Line 28 | char   *av[]
28          char    *compath;
29          int     p0[2], p1[2];
30  
31 <        pd->pid = 0;
31 >        pd->pid = -1;
32          pd->running = 0;                /* not going yet */
33          
34          if (av == NULL)                 /* cloning operation? */
# Line 37 | Line 37 | char   *av[]
37                  return(0);
38          if (pipe(p0) < 0 || pipe(p1) < 0)
39                  return(-1);
40 <        if ((pd->pid = fork()) == 0) {  /* if child... */
40 > #ifdef BSD
41 >        if (compath != NULL)
42 >                pd->pid = vfork();      /* more efficient with exec() */
43 >        else
44 > #endif
45 >        pd->pid = fork();
46 >        if (pd->pid == 0) {             /* if child... */
47                  close(p0[1]);
48                  close(p1[0]);
49                  if (p0[0] != 0) {       /* connect p0 to stdin */
# Line 88 | Line 94 | int nproc
94                          close(pd[i].w);
95                          close(pd[i].r);
96                          pd[i].running = 0;
97 <                }
97 >                } else
98 >                        togo -= (pd[i].pid < 0);
99          if (nproc == 1) {                       /* await specific process? */
100                  if (waitpid(pd->pid, &status, 0) != pd->pid)
101                          return(-1);
102 <                pd->pid = 0;
102 >                pd->pid = -1;
103                  return(status>>8 & 0xff);
104          }
105                                                  /* else unordered wait */
106          while (togo > 0 && (pid = wait(&status)) >= 0) {
107                  for (i = nproc; i-- > 0; )
108                          if (pd[i].pid == pid) {
109 <                                pd[i].pid = 0;
109 >                                pd[i].pid = -1;
110                                  --togo;
111                                  break;
112                          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines