From: Willy Tarreau Date: Wed, 20 Apr 2016 08:33:15 +0000 (+0200) Subject: MEDIUM: unblock signals on startup. X-Git-Tag: v1.7-dev3~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d50b4ac0d4acb00e0d2386198191ac329e8dbb77;p=thirdparty%2Fhaproxy.git MEDIUM: unblock signals on startup. A problem was reported recently by some users of programs compiled with Go 1.5 which by default blocks all signals before executing processes, resulting in haproxy not receiving SIGUSR1 or even SIGTERM, causing lots of zombie processes. This problem was apparently observed by users of consul and kubernetes (at least). This patch is a workaround for this issue. It consists in unblocking all signals on startup. Since they're normally not blocked in a regular shell, it ensures haproxy always starts under the same conditions. Quite useful information reported by both Matti Savolainen and REN Xiaolei actually helped find the root cause of this problem and this workaround. Thanks to them for this. This patch must be backported to 1.6 and 1.5 where the problem is observed. --- diff --git a/src/signal.c b/src/signal.c index e9301edaf3..7b72622572 100644 --- a/src/signal.c +++ b/src/signal.c @@ -105,6 +105,14 @@ int signal_init() signal_queue_len = 0; memset(signal_queue, 0, sizeof(signal_queue)); memset(signal_state, 0, sizeof(signal_state)); + + /* Ensure signals are not blocked. Some shells or service managers may + * accidently block all of our signals unfortunately, causing lots of + * zombie processes to remain in the background during reloads. + */ + sigemptyset(&blocked_sig); + sigprocmask(SIG_SETMASK, &blocked_sig, NULL); + sigfillset(&blocked_sig); sigdelset(&blocked_sig, SIGPROF); for (sig = 0; sig < MAX_SIGNAL; sig++)