From: William Lallemand Date: Tue, 11 Sep 2018 08:06:21 +0000 (+0200) Subject: MEDIUM: mworker: block SIGCHLD until the master is ready X-Git-Tag: v1.9-dev2~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ebf304f8dd02497ceaf6f50b50afc59c26a77ee1;p=thirdparty%2Fhaproxy.git MEDIUM: mworker: block SIGCHLD until the master is ready With the new way of handling the signals in the master worker, we are are not staying in a waitpid() loop. Which means that we need to catch the SIGCHLD signals to call waitpid(). The problem is when the master is reloading, this signal is neither registered nor blocked so we lost all signals between the restart and the call to mworker_loop(). This patch blocks the SIGCHLD signals before the reloading and ensure it's not unblocked before the master registered the SIGCHLD handler. --- diff --git a/src/haproxy.c b/src/haproxy.c index 1ab87b7267..69d42da74f 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -493,6 +493,7 @@ static void mworker_block_signals() sigaddset(&set, SIGHUP); sigaddset(&set, SIGINT); sigaddset(&set, SIGTERM); + sigaddset(&set, SIGCHLD); ha_sigmask(SIG_SETMASK, &set, NULL); } @@ -506,6 +507,7 @@ static void mworker_unblock_signals() sigaddset(&set, SIGHUP); sigaddset(&set, SIGINT); sigaddset(&set, SIGTERM); + sigaddset(&set, SIGCHLD); ha_sigmask(SIG_UNBLOCK, &set, NULL); } diff --git a/src/signal.c b/src/signal.c index 01b6121799..6f74a6f46f 100644 --- a/src/signal.c +++ b/src/signal.c @@ -118,6 +118,8 @@ int signal_init() * parsing We don't want the process to be killed by an unregistered * USR2 signal when the master-worker is reloading */ sigaddset(&blocked_sig, SIGUSR2); + sigaddset(&blocked_sig, SIGCHLD); + ha_sigmask(SIG_SETMASK, &blocked_sig, NULL); sigfillset(&blocked_sig);