forked from external/yambar
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:
parent
c911d20e73
commit
8702378c74
1 changed files with 14 additions and 0 deletions
|
@ -377,6 +377,20 @@ run(struct module *mod)
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
/* Child */
|
/* 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);
|
setpgid(0, 0);
|
||||||
|
|
||||||
/* Close pipe read ends */
|
/* Close pipe read ends */
|
||||||
|
|
Loading…
Add table
Reference in a new issue