git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] Allow run_command stdout_to_stderr when stderr is a pipe
@ 2008-02-14  6:22 Shawn O. Pearce
  0 siblings, 0 replies; only message in thread
From: Shawn O. Pearce @ 2008-02-14  6:22 UTC (permalink / raw)
  To: git

To allow receive-pack hooks to have their stdout and stderr streams
redirected to the same pipe we need to setup the pipe on fd 2 before
we dup fd 2 over to fd 1.  This way we can use a single pipe to
capture both stdout and stderr and redirect it to a sideband channel,
or elsewhere.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 run-command.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/run-command.c b/run-command.c
index 476d00c..52f80be 100644
--- a/run-command.c
+++ b/run-command.c
@@ -75,6 +75,13 @@ int start_command(struct child_process *cmd)
 			close(cmd->in);
 		}
 
+		if (cmd->no_stderr)
+			dup_devnull(2);
+		else if (need_err) {
+			dup2(fderr[1], 2);
+			close_pair(fderr);
+		}
+
 		if (cmd->no_stdout)
 			dup_devnull(1);
 		else if (cmd->stdout_to_stderr)
@@ -87,13 +94,6 @@ int start_command(struct child_process *cmd)
 			close(cmd->out);
 		}
 
-		if (cmd->no_stderr)
-			dup_devnull(2);
-		else if (need_err) {
-			dup2(fderr[1], 2);
-			close_pair(fderr);
-		}
-
 		if (cmd->dir && chdir(cmd->dir))
 			die("exec %s: cd to %s failed (%s)", cmd->argv[0],
 			    cmd->dir, strerror(errno));
-- 
1.5.4.1.1309.g833c2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-02-14  6:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-14  6:22 [PATCH 1/6] Allow run_command stdout_to_stderr when stderr is a pipe Shawn O. Pearce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).