summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-03-17 19:20:04 -0400
committerJunio C Hamano <gitster@pobox.com>2017-03-18 10:29:15 -0700
commit7b91929ba0422435c193c506dbaa593964be6e84 (patch)
tree33eca4e54f034cf2d6a96067950f02b5787a8244
parent46df6906f3aaf74dafe2026b028c8c5c1a0d5f58 (diff)
downloadgit-7b91929ba0422435c193c506dbaa593964be6e84.tar.gz
run-command: fix segfault when cleaning forked async processjk/execv-dashed-external
Callers of the run-command API may mark a child as "clean_on_exit"; it gets added to a list and killed when the main process dies. Since commit 46df6906f (execv_dashed_external: wait for child on signal death, 2017-01-06), we respect an extra "wait_after_clean" flag, which we expect to find in the child_process struct. When Git is built with NO_PTHREADS, we start "struct async" processes by forking rather than spawning a thread. The resulting processes get added to the cleanup list but they don't have a child_process struct, and the cleanup function ends up dereferencing NULL. We should notice this case and assume that the processes do not need to be waited for (i.e., the same behavior they had before 46df6906f). Reported-by: Brandon Williams <bmwill@google.com> Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--run-command.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/run-command.c b/run-command.c
index 73bfba7ef9..7dc8a8e70e 100644
--- a/run-command.c
+++ b/run-command.c
@@ -48,7 +48,7 @@ static void cleanup_children(int sig, int in_signal)
kill(p->pid, sig);
- if (p->process->wait_after_clean) {
+ if (p->process && p->process->wait_after_clean) {
p->next = children_to_wait_for;
children_to_wait_for = p;
} else {