From: Vincent Bernat Date: Sun, 22 Oct 2017 19:04:29 +0000 (+0200) Subject: priv: provide a simpler sig_chld when priv sep is disabled X-Git-Tag: 0.9.9~6^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=95f43afa5c39702b3d01e31df18bd2bd01e7c4bc;p=thirdparty%2Flldpd.git 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. --- 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