aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel Wesley Filardo <nfilardo@microsoft.com>2021-01-14 22:18:53 +0000
committerNathaniel Wesley Filardo <nfilardo@microsoft.com>2021-01-20 17:09:48 +0000
commiteee9db9d115d91aa82f33685c4e76d656db92976 (patch)
tree5978d3ecf0b313ceab12207ba8dcb399ceb13855
parentbacb71f1c3ed5f40e393afd8be81bedfba13a401 (diff)
downloadslirp-eee9db9d115d91aa82f33685c4e76d656db92976.zip
slirp-eee9db9d115d91aa82f33685c4e76d656db92976.tar.gz
slirp-eee9db9d115d91aa82f33685c4e76d656db92976.tar.bz2
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.
-rw-r--r--src/misc.c8
1 files changed, 8 insertions, 0 deletions
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
}