module/script: restore signal handlers and mask in child process

This fixes the issue where `killpg()` didn’t manage to kill the
sub-process tree.
This commit is contained in:
Daniel Eklöf 2020-10-25 16:06:16 +01:00
parent c911d20e73
commit 8702378c74
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -377,6 +377,20 @@ run(struct module *mod)
if (pid == 0) {
/* Child */
/* Restore signal handlers */
sigset_t mask;
sigemptyset(&mask);
const struct sigaction sa = {.sa_handler = SIG_DFL};
if (sigaction(SIGINT, &sa, NULL) < 0 ||
sigaction(SIGTERM, &sa, NULL) < 0 ||
sigaction(SIGCHLD, &sa, NULL) < 0 ||
sigprocmask(SIG_SETMASK, &mask, NULL) < 0)
{
goto fail;
}
setpgid(0, 0);
/* Close pipe read ends */