58 |
|
p1[1] = pd->w; |
59 |
|
} else if (pipe(p1) < 0) |
60 |
|
return(-1); |
61 |
– |
#ifdef BSD |
62 |
– |
if (compath != NULL) |
63 |
– |
pd->pid = vfork(); /* more efficient with exec() */ |
64 |
– |
else |
65 |
– |
#endif |
61 |
|
pd->pid = fork(); |
62 |
|
if (pd->pid == 0) { /* if child... */ |
63 |
|
close(p0[1]); |
129 |
|
|
130 |
|
for (i = 0; i < nproc; i++) /* close pipes, first */ |
131 |
|
if (pd[i].flags & PF_RUNNING) { |
132 |
< |
close(pd[i].w); |
133 |
< |
close(pd[i].r); |
132 |
> |
if (pd[i].w >= 0) close(pd[i].w); |
133 |
> |
if (pd[i].r >= 0) close(pd[i].r); |
134 |
|
pd[i].flags &= ~PF_RUNNING; |
135 |
|
} else |
136 |
|
togo -= (pd[i].pid < 0); |