561 |
error (1, errno, "cannot fork"); |
error (1, errno, "cannot fork"); |
562 |
if (pid == 0) |
if (pid == 0) |
563 |
{ |
{ |
564 |
if (dup2 (to_child_pipe[0], STDIN_FILENO) < 0) |
/* The child. */ |
565 |
error (1, errno, "cannot dup2 pipe"); |
|
566 |
|
/* The parent uses these ends of the pipes. */ |
567 |
if (close (to_child_pipe[1]) < 0) |
if (close (to_child_pipe[1]) < 0) |
568 |
error (1, errno, "cannot close pipe"); |
error (1, errno, "cannot close pipe"); |
569 |
if (close (from_child_pipe[0]) < 0) |
if (close (from_child_pipe[0]) < 0) |
570 |
error (1, errno, "cannot close pipe"); |
error (1, errno, "cannot close pipe"); |
571 |
|
|
572 |
|
/* Fool an unwitting child into reading from and writing to |
573 |
|
* the pipes. |
574 |
|
*/ |
575 |
|
if (dup2 (to_child_pipe[0], STDIN_FILENO) < 0) |
576 |
|
error (1, errno, "cannot dup2 pipe"); |
577 |
if (dup2 (from_child_pipe[1], STDOUT_FILENO) < 0) |
if (dup2 (from_child_pipe[1], STDOUT_FILENO) < 0) |
578 |
error (1, errno, "cannot dup2 pipe"); |
error (1, errno, "cannot dup2 pipe"); |
579 |
|
|
580 |
|
/* Don't need these fds after the dup2. */ |
581 |
|
if (close (to_child_pipe[0]) < 0) |
582 |
|
error (1, errno, "cannot close pipe"); |
583 |
|
if (close (from_child_pipe[1]) < 0) |
584 |
|
error (1, errno, "cannot close pipe"); |
585 |
|
|
586 |
if (fix_stderr) |
if (fix_stderr) |
587 |
work_around_openssh_glitch (); |
work_around_openssh_glitch (); |
588 |
|
|
590 |
execvp ((char *)command[0], (char **)command); |
execvp ((char *)command[0], (char **)command); |
591 |
error (1, errno, "cannot exec %s", command[0]); |
error (1, errno, "cannot exec %s", command[0]); |
592 |
} |
} |
593 |
|
|
594 |
|
/* The parent. */ |
595 |
if (close (to_child_pipe[0]) < 0) |
if (close (to_child_pipe[0]) < 0) |
596 |
error (1, errno, "cannot close pipe"); |
error (1, errno, "cannot close pipe"); |
597 |
if (close (from_child_pipe[1]) < 0) |
if (close (from_child_pipe[1]) < 0) |