summaryrefslogtreecommitdiff
path: root/run-command.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-01-07 12:42:43 +0100
committerJunio C Hamano <gitster@pobox.com>2012-01-08 15:06:35 -0800
commitafe19ff7b55129d988e421ae1e0df4ec9659787a (patch)
treeb751bccbe3d1ec95451b26a26d3a775193fc65c6 /run-command.h
parenteac2d83247ea0a265d923518c26873bb12c33778 (diff)
downloadgit-afe19ff7b55129d988e421ae1e0df4ec9659787a.tar.gz
run-command: optionally kill children on exit
When we spawn a helper process, it should generally be done and finish_command called before we exit. However, if we exit abnormally due to an early return or a signal, the helper may continue to run in our absence. In the best case, this may simply be wasted CPU cycles or a few stray messages on a terminal. But it could also mean a process that the user thought was aborted continues to run to completion (e.g., a push's pack-objects helper will complete the push, even though you killed the push process). This patch provides infrastructure for run-command to keep track of PIDs to be killed, and clean them on signal reception or input, just as we do with tempfiles. PIDs can be added in two ways: 1. If NO_PTHREADS is defined, async helper processes are automatically marked. By definition this code must be ready to die when the parent dies, since it may be implemented as a thread of the parent process. 2. If the run-command caller specifies the "clean_on_exit" option. This is not the default, as there are cases where it is OK for the child to outlive us (e.g., when spawning a pager). PIDs are cleared from the kill-list automatically during wait_or_whine, which is called from finish_command and finish_async. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'run-command.h')
-rw-r--r--run-command.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/run-command.h b/run-command.h
index 56491b9f23..2a6946668b 100644
--- a/run-command.h
+++ b/run-command.h
@@ -38,6 +38,7 @@ struct child_process {
unsigned silent_exec_failure:1;
unsigned stdout_to_stderr:1;
unsigned use_shell:1;
+ unsigned clean_on_exit:1;
void (*preexec_cb)(void);
};