From: "Shawn O. Pearce" <spearce@spearce.org>
To: git@vger.kernel.org
Subject: [PATCH 1/6] Allow run_command stdout_to_stderr when stderr is a pipe
Date: Thu, 14 Feb 2008 01:22:19 -0500 [thread overview]
Message-ID: <20080214062219.GA30516@spearce.org> (raw)
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
reply other threads:[~2008-02-14 6:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080214062219.GA30516@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.