{
int fdin[2], fdout[2];
int r;
-
+ pid_t pid1, pid2;
+
/* The buffer is NUL terminated, and we don't need that. */
n--;
file_error(ms, errno, "cannot create pipe");
return 0;
}
- switch (fork()) {
+ switch ((pid1=fork())) {
case 0: /* child */
(void) close(0);
(void) dup(fdin[0]);
(void) close(fdin[0]);
(void) close(fdout[1]);
/* fork again, to avoid blocking because both pipes filled */
- switch (fork()) {
+ switch ((pid2=fork())) {
case 0: /* child */
(void)close(fdout[0]);
if (swrite(fdin[1], old, n) != n)
if (fdin[1] != -1)
(void) close(fdin[1]);
(void) close(fdout[0]);
-#ifdef WNOHANG
- while (waitpid(-1, NULL, WNOHANG) != -1)
- continue;
-#else
- (void)wait(NULL);
-#endif
+ waitpid(pid1, NULL, 0);
+ waitpid(pid2, NULL, 0);
return n;
}
/*@notreached@*/