From 95f43afa5c39702b3d01e31df18bd2bd01e7c4bc Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sun, 22 Oct 2017 21:04:29 +0200 Subject: [PATCH] priv: provide a simpler sig_chld when priv sep is disabled We restore the original sig_chld() helper function when privilege separation is enabled but we use a very simple one when not. This should still fix the zombie issue. --- src/daemon/priv.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/daemon/priv.c b/src/daemon/priv.c index 2412d80d..6db6d49f 100644 --- a/src/daemon/priv.c +++ b/src/daemon/priv.c @@ -498,14 +498,11 @@ sig_chld(int sig) int rc = waitpid(monitored, &status, WNOHANG); if (rc == 0) { while ((rc = waitpid(-1, &status, WNOHANG)) > 0) { - if (monitored != -1 && rc == monitored) - priv_exit_rc_status(rc, status); + if (rc == monitored) priv_exit_rc_status(rc, status); } return; } - if (monitored != -1) - /* Monitored process not here anymore */ - priv_exit_rc_status(rc, status); + priv_exit_rc_status(rc, status); } /* Initialization */ @@ -585,6 +582,17 @@ priv_setup_chroot(const char *chrootdir) close(source); close(destination); } +#else /* !ENABLE_PRIVSEP */ + +/* Reap any children. It should only be lldpcli since there is not monitored + * process. */ +static void +sig_chld(int sig) +{ + int status = 0; + while (waitpid(-1, &status, WNOHANG) > 0); +} + #endif void -- 2.39.5