summaryrefslogtreecommitdiff
path: root/run-command.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-11-11 02:29:37 -0500
committerJunio C Hamano <gitster@pobox.com>2007-11-11 17:09:55 -0800
commitb73a4397590df9582dd1c994cac30e55e26b0b1e (patch)
tree0b9e8f83a0f59e170954ea7d6b9d7e9c068d4941 /run-command.c
parenta3b0079c6a2e6336b061465623b8f2db308a6978 (diff)
downloadgit-b73a4397590df9582dd1c994cac30e55e26b0b1e.tar.gz
run-command: Support sending stderr to /dev/null
Some callers may wish to redirect stderr to /dev/null in some contexts, such as if they are executing a command only to get the exit status and don't want users to see whatever output it may produce as a side-effect of computing that exit status. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/run-command.c b/run-command.c
index d99a6c4ea7..476d00c218 100644
--- a/run-command.c
+++ b/run-command.c
@@ -41,7 +41,7 @@ int start_command(struct child_process *cmd)
cmd->close_out = 1;
}
- need_err = cmd->err < 0;
+ need_err = !cmd->no_stderr && cmd->err < 0;
if (need_err) {
if (pipe(fderr) < 0) {
if (need_in)
@@ -87,7 +87,9 @@ int start_command(struct child_process *cmd)
close(cmd->out);
}
- if (need_err) {
+ if (cmd->no_stderr)
+ dup_devnull(2);
+ else if (need_err) {
dup2(fderr[1], 2);
close_pair(fderr);
}