In the master/worker the workers will be child processes of the master
and should be reaped after they exit.
---
 src/haproxy.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/haproxy.c b/src/haproxy.c
index 3fe8889..99d8c0d 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -48,6 +48,7 @@
 #include <sys/prctl.h>
 #include <sys/capability.h>
 #endif
+#include <sys/wait.h>
 
 #ifdef DEBUG_FULL
 #include <assert.h>
@@ -287,6 +288,15 @@ void sig_listen(struct sig_handler *sh)
 }
 
 /*
+ * upon SIGCHLD reap child
+ */
+void sig_reaper(struct sig_handler *sh)
+{
+       int status;
+       while(waitpid(-1, &status, WNOHANG) > 0);
+}
+
+/*
  * this function dumps every server's state when the process receives SIGHUP.
  */
 void sig_dump_state(struct sig_handler *sh)
@@ -1045,6 +1055,7 @@ void run(int argc, char **argv)
        signal_register_fct(SIGQUIT, dump, SIGQUIT);
        signal_register_fct(SIGUSR1, sig_soft_stop, SIGUSR1);
        signal_register_fct(SIGHUP, sig_dump_state, SIGHUP);
+       signal_register_fct(SIGCHLD, sig_reaper, SIGCHLD);
 
        /* Always catch SIGPIPE even on platforms which define MSG_NOSIGNAL.
         * Some recent FreeBSD setups report broken pipes, and MSG_NOSIGNAL
-- 
1.7.2.3


Reply via email to