path: root/run-command.c
diff options
authorbert Dvornik <>2010-05-20 18:57:52 (GMT)
committerJunio C Hamano <>2010-05-20 23:11:29 (GMT)
commitfc012c2810c237dd2299a3fc85b18c2beb60b730 (patch)
tree41bc04928e0a2ab24f2c28b8f8c2da153de0820e /run-command.c
parent60890cc60ccfc7000791a47f1f3d69fdb8884dd7 (diff)
start_command: close cmd->err descriptor when fork/spawn fails
Fix the problem where the cmd->err passed into start_command wasn't being properly closed when certain types of errors occurr. (Compare the affected code with the clean shutdown code later in the function.) On Windows, this problem would be triggered if mingw_spawnvpe() failed, which would happen if the command to be executed was malformed (e.g. a text file that didn't start with a #! line). If cmd->err was a pipe, the failure to close it could result in a hang while the other side was waiting (forever) for either input or pipe close, e.g. while trying to shove the output into the side band. On msysGit, this problem was causing a hang in t5516-fetch-push. [J6t: With a slight adjustment of the test case, the hang is also observed on Linux.] Signed-off-by: bert Dvornik <> Signed-off-by: Johannes Sixt <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'run-command.c')
1 files changed, 2 insertions, 0 deletions
diff --git a/run-command.c b/run-command.c
index eb5c575..c7793f5 100644
--- a/run-command.c
+++ b/run-command.c
@@ -383,6 +383,8 @@ fail_pipe:
if (need_err)
+ else if (cmd->err)
+ close(cmd->err);
errno = failed_errno;
return -1;