From eee9db9d115d91aa82f33685c4e76d656db92976 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Thu, 14 Jan 2021 22:18:53 +0000 Subject: fork_exec_child_setup: improve signal handling Blocked signal state is inherited across exec(), so let's zero that out rather than inherit whatever it was when we spawned the child. POSIX has some strange rules about SIG_IGN'd SIGCHLD across exec, so let's not do that, just for consistency. --- src/misc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/misc.c b/src/misc.c index e6bc0a2..12487b2 100644 --- a/src/misc.c +++ b/src/misc.c @@ -136,6 +136,14 @@ static void fork_exec_child_setup(gpointer data) { #ifndef _WIN32 setsid(); + + /* Unblock all signals and leave our exec()-ee to block what it wants */ + sigset_t ss; + sigemptyset(&ss); + sigprocmask(SIG_SETMASK, &ss, NULL); + + /* POSIX is obnoxious about SIGCHLD specifically across exec() */ + signal(SIGCHLD, SIG_DFL); #endif } -- cgit v1.1