@matheusbsbs / matheus-bagliano / commits / f0b7367cb1
Fork 0

Restore SIGCHLD to SIG_DFL where we care about waitpid().

It was reported that under one implementation of socks client "git clone" fails with "error: waitpid failed (No child processes)", because "git" is spawned after setting SIGCHLD to SIG_IGN. Arguably it may be a broken setting, but we should protect ourselves so that we can get reliable results from waitpid() for the children we care about. This patch resets SIGCHLD to SIG_DFL in three places: - connect.c::git_connect() - initiators of git native protocol transfer are covered with this. - daemon.c::main() - obviously. - merge-index.c::main() - obviously. There are other programs that do fork() but do not waitpid(): http-push, imap-send. upload-pack does not either, but in the case of that program, each of the forked halves runs exec() another program, so this change would not have much effect there. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jun 19, 2006 at 18:25 UTC f0b7367cb124a628b80697f5ed095c5859022e21
3 files changed +15
connect.c
+5
@@ -581,6 +581,11 @@ int git_connect(int fd[2], char *url, const char *prog)
581 enum protocol protocol = PROTO_LOCAL;
582 int free_path = 0;
583
584 + /* Without this we cannot rely on waitpid() to tell
585 + * what happened to our children.
586 + */
587 + signal(SIGCHLD, SIG_DFL);
588 +
589 host = strstr(url, "://");
590 if(host) {
591 *host = '\0';
daemon.c
+5
@@ -671,6 +671,11 @@ int main(int argc, char **argv)
671 int inetd_mode = 0;
672 int i;
673
674 + /* Without this we cannot rely on waitpid() to tell
675 + * what happened to our children.
676 + */
677 + signal(SIGCHLD, SIG_DFL);
678 +
679 for (i = 1; i < argc; i++) {
680 char *arg = argv[i];
681
merge-index.c
+5
@@ -99,6 +99,11 @@ int main(int argc, char **argv)
99 {
100 int i, force_file = 0;
101
102 + /* Without this we cannot rely on waitpid() to tell
103 + * what happened to our children.
104 + */
105 + signal(SIGCHLD, SIG_DFL);
106 +
107 if (argc < 3)
108 usage("git-merge-index [-o] [-q] <merge-program> (-a | <filename>*)");
109