]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
priv: provide a simpler sig_chld when priv sep is disabled fix/reap-children 251/head
authorVincent Bernat <vincent@bernat.im>
Sun, 22 Oct 2017 19:04:29 +0000 (21:04 +0200)
committerVincent Bernat <vincent@bernat.im>
Sun, 22 Oct 2017 19:04:29 +0000 (21:04 +0200)
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

index 2412d80d678062294b27c548b9b50a765f3e185e..6db6d49f033e313fb75eabaa8a5ad8430f5151a9 100644 (file)
@@ -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