diff --git a/run-command.c b/run-command.c index aba2bf2c0f..2ce8c2b2f0 100644 --- a/run-command.c +++ b/run-command.c @@ -132,6 +132,14 @@ int start_command(struct child_process *cmd) dup2(cmd->in, 0); } + if (cmd->no_stderr) { + s2 = dup(2); + dup_devnull(2); + } else if (need_err) { + s2 = dup(2); + dup2(fderr[1], 2); + } + if (cmd->no_stdout) { s1 = dup(1); dup_devnull(1); @@ -146,14 +154,6 @@ int start_command(struct child_process *cmd) dup2(cmd->out, 1); } - if (cmd->no_stderr) { - s2 = dup(2); - dup_devnull(2); - } else if (need_err) { - s2 = dup(2); - dup2(fderr[1], 2); - } - if (cmd->dir) die("chdir in start_command() not implemented"); if (cmd->env) {