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.9 by greg, Sat Dec 12 23:08:13 2009 UTC vs.
Revision 3.10 by greg, Thu Jun 14 05:13:25 2012 UTC

# Line 28 | Line 28 | char   *av[]
28          char    *compath;
29          int     p0[2], p1[2];
30  
31 <        pd->running = 0; /* not yet */
32 <                                        /* find executable */
33 <        compath = getpath(av[0], getenv("PATH"), 1);
34 <        if (compath == 0)
31 >        pd->running = 0;                /* not going yet */
32 >        
33 >        if (av == NULL)                 /* cloning operation? */
34 >                compath = NULL;
35 >        else if ((compath = getpath(av[0], getenv("PATH"), X_OK)) == NULL)
36                  return(0);
37          if (pipe(p0) < 0 || pipe(p1) < 0)
38                  return(-1);
39 <        if ((pd->pid = fork()) == 0) {          /* if child */
39 >        if ((pd->pid = fork()) == 0) {  /* if child... */
40                  close(p0[1]);
41                  close(p1[0]);
42                  if (p0[0] != 0) {       /* connect p0 to stdin */
# Line 46 | Line 47 | char   *av[]
47                          dup2(p1[1], 1);
48                          close(p1[1]);
49                  }
50 <                execv(compath, av);     /* exec command */
50 >                if (compath == NULL)    /* just cloning? */
51 >                        return(0);
52 >                execv(compath, av);     /* else exec command */
53                  perror(compath);
54                  _exit(127);
55          }
# Line 79 | Line 82 | SUBPROC *pd
82          if (!pd->running)
83                  return(0);
84          close(pd->w);
85 +        close(pd->r);
86          pd->running = 0;
87 <        if (waitpid(pd->pid, &status, 0) == pd->pid) {
84 <                close(pd->r);
87 >        if (waitpid(pd->pid, &status, 0) == pd->pid)
88                  return(status>>8 & 0xff);
89 <        }
89 >
90          return(-1);             /* ? unknown status */
91   }
92  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines