path: root/run-command.h
diff options
authorJeff King <>2012-01-07 11:42:43 (GMT)
committerJunio C Hamano <>2012-01-08 23:06:35 (GMT)
commitafe19ff7b55129d988e421ae1e0df4ec9659787a (patch)
treeb751bccbe3d1ec95451b26a26d3a775193fc65c6 /run-command.h
parenteac2d83247ea0a265d923518c26873bb12c33778 (diff)
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 <> Signed-off-by: Clemens Buchacher <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'run-command.h')
1 files changed, 1 insertions, 0 deletions
diff --git a/run-command.h b/run-command.h
index 56491b9..2a69466 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);