]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
When monitored process dies early, handle this case gracefully
authorVincent Bernat <vbernat@wanadooportails.com>
Fri, 21 Nov 2008 09:50:01 +0000 (10:50 +0100)
committerVincent Bernat <vbernat@wanadooportails.com>
Fri, 21 Nov 2008 09:50:01 +0000 (10:50 +0100)
src/priv.c

index 8935934a7a407c4a5f820afc9b25ffef92dd7d96..a2967bbbb5c4c4dc6efb4c462c5c5a7a81190850 100644 (file)
@@ -502,6 +502,7 @@ priv_init(char *chrootdir)
        struct passwd *user;
        struct group *group;
        gid_t gidset[1];
+        int status;
 
        /* Create socket pair */
        if (socketpair(AF_LOCAL, SOCK_DGRAM, PF_UNSPEC, pair) < 0)
@@ -552,6 +553,9 @@ priv_init(char *chrootdir)
                signal(SIGINT, sig_pass_to_chld);
                signal(SIGQUIT, sig_pass_to_chld);
                signal(SIGCHLD, sig_chld);
+                if (waitpid(monitored, &status, WNOHANG) != 0)
+                        /* Child is already dead */
+                        _exit(1);
                priv_loop();
                exit(0);
        }