{"thread":{"id":"52859","subject":"[PATCH] run-command.c: ensure signaled hook scripts are waited upon","startedAt":"2020-02-21T06:11:58Z","lastAt":"2020-02-22T17:12:28Z","messageCount":3,"participants":["Anthony Sottile","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"392260","messageId":"20200221060636.4507-1-asottile@umich.edu","threadId":"52859","inReplyTo":null,"subject":"[PATCH] run-command.c: ensure signaled hook scripts are waited upon","fromName":"Anthony Sottile","fromEmail":"asottile@umich.edu","sentAt":"2020-02-21T06:06:36Z","receivedAt":"2020-02-21T06:11:58Z","isPatch":true,"sender":{"key":"asottile@umich.edu","avatar":"https://avatars.githubusercontent.com/u/1810591?v=4"},"body":"In the event of a `^C` while hook scripts are running, ensure that the\nhook processes are cleaned up and do not become zombies.  This also ensures\nthat upon `^C` execution is not handed back to the terminal until the\nprocesses have been waited upon.\n\nSigned-off-by: Anthony Sottile <asottile@umich.edu>\n---\n run-command.c | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/run-command.c b/run-command.c\nindex f5e1149..75d3b73 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1358,6 +1358,8 @@ int run_hook_ve(const char *const *env, const char *name, va_list args)\n \thook.no_stdin = 1;\n \thook.stdout_to_stderr = 1;\n \thook.trace2_hook_name = name;\n+\thook.clean_on_exit = 1;\n+\thook.wait_after_clean = 1;\n \n \treturn run_command(&hook);\n }\n-- \n2.25.GIT\n\n"},{"id":"392261","messageId":"20200221063954.GJ1280313@coredump.intra.peff.net","threadId":"52859","inReplyTo":"20200221060636.4507-1-asottile@umich.edu","subject":"Re: [PATCH] run-command.c: ensure signaled hook scripts are waited upon","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-02-21T06:39:54Z","receivedAt":"2020-02-21T06:39:58Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 20, 2020 at 10:06:36PM -0800, Anthony Sottile wrote:\n\n> In the event of a `^C` while hook scripts are running, ensure that the\n> hook processes are cleaned up and do not become zombies.  This also ensures\n> that upon `^C` execution is not handed back to the terminal until the\n> processes have been waited upon.\n\nIf we assume that most people would prefer this \"wait until the hook has\ndied\" behavior, I think this shouldn't have any unwanted secondary\neffects. I'm on the fence on whether it's what most people would want or\nnot (I guess most people don't care either way, because their scripts\ndon't ignore SIGINT).\n\n(Earlier in the thread, we discussed possibly swapping the order of the\ncleanup code and dropping the signal handler, which could have more\nunexpected effects, but that part isn't in this patch).\n\n-Peff\n"},{"id":"392299","messageId":"xmqqblpq7dho.fsf@gitster-ct.c.googlers.com","threadId":"52859","inReplyTo":"20200221063954.GJ1280313@coredump.intra.peff.net","subject":"Re: [PATCH] run-command.c: ensure signaled hook scripts are waited upon","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-02-22T17:12:19Z","receivedAt":"2020-02-22T17:12:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> If we assume that most people would prefer this \"wait until the hook has\n> died\" behavior, I think this shouldn't have any unwanted secondary\n> effects. I'm on the fence on whether it's what most people would want or\n> not (I guess most people don't care either way, because their scripts\n> don't ignore SIGINT).\n\nYeah, and imagining why they deliberately ignore INT (i.e. \"because\nI want this hook not be interrupted and run to its completion\") does\nnot help guess if they want git to wait for hook's completion or\njust go ahead and die of its own signal death.  We could timeout the\nwaiting and kill such a child forcibly, and that may avoid these\nhook script that ignore INT to hang around, but I do not know if\nthat is desirable.\n\n\n"}]}