X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=run-command.c;h=44100a749b09439121073e32e7a3143b54185d31;hb=77d3ecee85dbf354d2059d7ef65d788d90db3efa;hp=743757c36ec0e5667fd8af28800ac095f1581adb;hpb=5a4d707a6d914fcea302e299fc18892d9e42c767;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));