summaryrefslogtreecommitdiffstats
path: root/usr.sbin/hotplugd
diff options
context:
space:
mode:
authorkurt <kurt@openbsd.org>2009-06-26 01:06:04 +0000
committerkurt <kurt@openbsd.org>2009-06-26 01:06:04 +0000
commit26baf48053294210e707d7e437ccdf972d21950d (patch)
tree1c9072f410a56dbf4bfe6eaf929e899b1d8a7443 /usr.sbin/hotplugd
parentdo not use nitems(); ok claudio (diff)
downloadwireguard-openbsd-26baf48053294210e707d7e437ccdf972d21950d.tar.xz
wireguard-openbsd-26baf48053294210e707d7e437ccdf972d21950d.zip
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@
Diffstat (limited to 'usr.sbin/hotplugd')
-rw-r--r--usr.sbin/hotplugd/hotplugd.c15
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;