diff options
author | Kurt Miller <kurt@cvs.openbsd.org> | 2009-06-26 01:06:05 +0000 |
---|---|---|
committer | Kurt Miller <kurt@cvs.openbsd.org> | 2009-06-26 01:06:05 +0000 |
commit | 108fcb5d570793be6331cf6f32bf84b76b52e24b (patch) | |
tree | 021e4c0c168fc08ae6b1d676d7b05ab34c7ff8a0 | |
parent | 45c30a5c60ea1887f7fb096ff31b560860586936 (diff) |
If two or more children exit before hotplugd is scheduled only one SIGCHLD
will be delivered, so deal with this case in the SIGCHLD handler. Also
retry if waitpid() fails with EINTR. looks good deraadt@ millert@
-rw-r--r-- | usr.sbin/hotplugd/hotplugd.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.sbin/hotplugd/hotplugd.c b/usr.sbin/hotplugd/hotplugd.c index 4142a6115f0..ba6e83977e2 100644 --- a/usr.sbin/hotplugd/hotplugd.c +++ b/usr.sbin/hotplugd/hotplugd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hotplugd.c,v 1.10 2009/06/10 18:50:43 guenther Exp $ */ +/* $OpenBSD: hotplugd.c,v 1.11 2009/06/26 01:06:04 kurt Exp $ */ /* * Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org> * @@ -174,8 +174,15 @@ sigchild(int signum) sdata.log_fac = _LOG_FACILITY; sdata.log_stat = _LOG_OPT; - pid = waitpid(WAIT_ANY, &status, 0); - if (pid != -1) { + while ((pid = waitpid(WAIT_ANY, &status, WNOHANG)) != 0) { + if (pid == -1) { + if (errno == EINTR) + continue; + if (errno != ECHILD) + syslog_r(LOG_ERR, &sdata, "waitpid: %m"); + break; + } + if (WIFEXITED(status)) { if (WEXITSTATUS(status) != 0) { syslog_r(LOG_NOTICE, &sdata, @@ -186,8 +193,6 @@ sigchild(int signum) syslog_r(LOG_NOTICE, &sdata, "child is terminated abnormally"); } - } else if (errno != ECHILD) { - syslog_r(LOG_ERR, &sdata, "waitpid: %m"); } errno = saved_errno; |