From: Vincent Bernat Date: Fri, 21 Nov 2008 09:50:01 +0000 (+0100) Subject: When monitored process dies early, handle this case gracefully X-Git-Tag: 0.3~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=90149ee346a2c242776b32e2ed38c472d09b70b6;p=thirdparty%2Flldpd.git When monitored process dies early, handle this case gracefully --- diff --git a/src/priv.c b/src/priv.c index 8935934a..a2967bbb 100644 --- a/src/priv.c +++ b/src/priv.c @@ -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); }