diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-11-02 14:23:50 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2012-11-02 14:23:50 +0000 |
commit | 5d3006c15b704935b68ae9093f3eb60b72d19676 (patch) | |
tree | c2e01007cf5d5a53c8ff4d734b867b431cd628c0 /sbin | |
parent | 89e143c61dacbad7230c83f06c8621aa43ca377d (diff) |
Watch the non-privileged end of the pipe to the privileged child
process. So when the child dies, the parent exits immediately.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/dispatch.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index 12cef266123..cb48bd9ef24 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.60 2012/10/30 18:39:44 krw Exp $ */ +/* $OpenBSD: dispatch.c,v 1.61 2012/11/02 14:23:49 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -109,7 +109,7 @@ void dispatch(void) { int count, to_msec; - struct pollfd fds[2]; + struct pollfd fds[3]; time_t cur_time, howlong; void (*func)(void); @@ -154,10 +154,11 @@ another: fds[0].fd = ifi->rfdesc; fds[1].fd = routefd; /* Could be -1, which will be ignored. */ - fds[0].events = fds[1].events = POLLIN; + fds[2].fd = privfd; + fds[0].events = fds[1].events = fds[2].events = POLLIN; - /* Wait for a packet or a timeout... XXX */ - count = poll(fds, 2, to_msec); + /* Wait for a packet or a timeout or privfd ... XXX */ + count = poll(fds, 3, to_msec); /* Not likely to be transitory... */ if (count == -1) { @@ -175,6 +176,9 @@ another: if (ifi) routehandler(); } + if ((fds[2].revents & (POLLIN | POLLHUP))) { + error("lost connection to [priv]"); + } } while (1); } |