git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] start_command: close cmd->err descriptor when fork/spawn fails
@ 2010-04-26  1:15 bert Dvornik
  2010-04-26  6:16 ` Johannes Sixt
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: bert Dvornik @ 2010-04-26  1:15 UTC (permalink / raw)
  To: git, msysgit; +Cc: Johannes Schindelin, Johannes Sixt, bert Dvornik

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>
---
 run-command.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/run-command.c b/run-command.c
index d1a8ceb..41666ac 100644
--- a/run-command.c
+++ b/run-command.c
@@ -383,6 +383,8 @@ fail_pipe:
 			close(cmd->out);
 		if (need_err)
 			close_pair(fderr);
+		else if (cmd->err)
+			close(cmd->err);
 		errno = failed_errno;
 		return -1;
 	}
-- 
1.7.1.rc1.1794.g4bea1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-04-26 23:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-26  1:15 [PATCH] start_command: close cmd->err descriptor when fork/spawn fails bert Dvornik
2010-04-26  6:16 ` Johannes Sixt
2010-04-26  6:29 ` Johannes Schindelin
2010-04-26  6:48 ` Johannes Sixt
2010-04-26 11:47   ` Albert Dvornik
2010-04-26 23:58     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).