mirror of
https://github.com/git/git.git
synced 2026-03-13 02:13:24 +01:00
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>
This commit is contained in:
committed by
Johannes Schindelin
parent
ee59bcd37d
commit
f6a2f432a2
@@ -385,6 +385,8 @@ fail_pipe:
|
||||
close(cmd->out);
|
||||
if (need_err)
|
||||
close_pair(fderr);
|
||||
else if (cmd->err)
|
||||
close(cmd->err);
|
||||
errno = failed_errno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user