summaryrefslogtreecommitdiff
path: root/run-command.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-02-05 12:57:37 -0800
committerJunio C Hamano <gitster@pobox.com>2010-02-05 20:57:16 -0800
commit4f41b611481bad08319966f7787fc7c4c7bfaa52 (patch)
tree3a333aed6eefc5c10742efc2dce64741e3fdc837 /run-command.c
parent2b26e0e18907132eaac2a8163de0cac552217082 (diff)
downloadgit-4f41b611481bad08319966f7787fc7c4c7bfaa52.tar.gz
run-command: Allow stderr to be a caller supplied pipe
Like .out, .err may now be set to a file descriptor > 0, which is a writable pipe/socket/file that the child's stderr will be redirected into. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/run-command.c b/run-command.c
index cf2d8f7fae..bfd231243d 100644
--- a/run-command.c
+++ b/run-command.c
@@ -94,6 +94,9 @@ fail_pipe:
else if (need_err) {
dup2(fderr[1], 2);
close_pair(fderr);
+ } else if (cmd->err > 1) {
+ dup2(cmd->err, 2);
+ close(cmd->err);
}
if (cmd->no_stdout)
@@ -156,6 +159,9 @@ fail_pipe:
} else if (need_err) {
s2 = dup(2);
dup2(fderr[1], 2);
+ } else if (cmd->err > 2) {
+ s2 = dup(2);
+ dup2(cmd->err, 2);
}
if (cmd->no_stdout) {
@@ -228,6 +234,8 @@ fail_pipe:
if (need_err)
close(fderr[1]);
+ else if (cmd->err)
+ close(cmd->err);
return 0;
}