Forked processes does not receive signals
stacyharper opened this issue · 0 comments
stacyharper commented
@emersion mentionned that the forked process probably still got the signal masks of swayidle
A child created via fork(2) inherits a copy of its parent's signal mask; the signal mask is preserved across execve(2).
I tried something like this without succes :(
diff --git a/main.c b/main.c
index 1a790e4..3933327 100644
--- a/main.c
+++ b/main.c
@@ -148,6 +148,9 @@ static void cmd_exec(char *param) {
pid = fork();
}
if (pid == 0) {
+ signal(SIGINT, SIG_DFL);
+ signal(SIGTERM, SIG_DFL);
+ signal(SIGUSR1, SIG_DFL);
char *const cmd[] = { "sh", "-c", param, NULL, };
execvp(cmd[0], cmd);
swayidle_log_errno(LOG_ERROR, "execve failed!");
edit: It looks like fork
should be enough to reset signals handlers
A child created via fork(2) initially has an empty pending signal set; the pending signal set is preserved across an execve(2).