start_command: close cmd->err descriptor when fork/spawn fails
commit12a5a33704cd5ac56e81d87a2474589fe9509d41
authorbert Dvornik <dvornik+git@gmail.com>
Mon, 26 Apr 2010 01:15:40 +0000 (25 21:15 -0400)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 28 Apr 2010 14:25:05 +0000 (28 16:25 +0200)
tree07f92cd61e8f7b92f6aa6db13be236fbf19aa55b
parente4d2b8a830f19800a9812820c924d699d4c39ede
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.

I'm not sure why (or if) this problem hasn't cropped up under Linux.
The non-Windows code *does* try to check for execve() failures in the
child, in addition to the fork() failures.

Signed-off-by: bert Dvornik <dvornik+git@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
run-command.c