X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=run-command.c;h=44100a749b09439121073e32e7a3143b54185d31;hb=653194758ee338b7c87d011007c532ed5cf68d45;hp=743757c36ec0e5667fd8af28800ac095f1581adb;hpb=dfb9a34ababeee98a9f241636c1fe6e98c754f7a;p=git.git diff --git a/run-command.c b/run-command.c index 743757c36..44100a749 100644 --- a/run-command.c +++ b/run-command.c @@ -91,6 +91,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) @@ -103,13 +110,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));