[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Cvs-cvs] Changes to ccvs/src/run.c
From: |
Derek Robert Price |
Subject: |
[Cvs-cvs] Changes to ccvs/src/run.c |
Date: |
Mon, 03 Oct 2005 15:35:52 -0400 |
Index: ccvs/src/run.c
diff -u ccvs/src/run.c:1.59 ccvs/src/run.c:1.60
--- ccvs/src/run.c:1.59 Thu Sep 29 20:20:34 2005
+++ ccvs/src/run.c Mon Oct 3 19:35:50 2005
@@ -561,15 +561,28 @@
error (1, errno, "cannot fork");
if (pid == 0)
{
- if (dup2 (to_child_pipe[0], STDIN_FILENO) < 0)
- error (1, errno, "cannot dup2 pipe");
+ /* The child. */
+
+ /* The parent uses these ends of the pipes. */
if (close (to_child_pipe[1]) < 0)
error (1, errno, "cannot close pipe");
if (close (from_child_pipe[0]) < 0)
error (1, errno, "cannot close pipe");
+
+ /* Fool an unwitting child into reading from and writing to
+ * the pipes.
+ */
+ if (dup2 (to_child_pipe[0], STDIN_FILENO) < 0)
+ error (1, errno, "cannot dup2 pipe");
if (dup2 (from_child_pipe[1], STDOUT_FILENO) < 0)
error (1, errno, "cannot dup2 pipe");
+ /* Don't need these fds after the dup2. */
+ if (close (to_child_pipe[0]) < 0)
+ error (1, errno, "cannot close pipe");
+ if (close (from_child_pipe[1]) < 0)
+ error (1, errno, "cannot close pipe");
+
if (fix_stderr)
work_around_openssh_glitch ();
@@ -577,6 +590,8 @@
execvp ((char *)command[0], (char **)command);
error (1, errno, "cannot exec %s", command[0]);
}
+
+ /* The parent. */
if (close (to_child_pipe[0]) < 0)
error (1, errno, "cannot close pipe");
if (close (from_child_pipe[1]) < 0)
- [Cvs-cvs] Changes to ccvs/src/run.c,
Derek Robert Price <=