From a91b1d34acba1e5ffb42ec08394b69167266e734 Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Fri, 6 Nov 2020 18:32:38 -0500 Subject: [PATCH] Check and clear events from poll() even if interrupted by signal. --- src/ifchd.c | 3 +-- src/ndhc.c | 6 ++---- src/sockd.c | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ifchd.c b/src/ifchd.c index 1e119a2..e5def3a 100644 --- a/src/ifchd.c +++ b/src/ifchd.c @@ -349,8 +349,7 @@ static void do_ifch_work(void) for (;;) { if (poll(pfds, 2, -1) < 0) { - if (errno == EINTR) continue; - else suicide("pollt failed"); + if (errno != EINTR) suicide("poll failed"); } if (pfds[0].revents & POLLIN) { pfds[0].revents &= ~POLLIN; diff --git a/src/ndhc.c b/src/ndhc.c index d4c4a24..16bbbc4 100644 --- a/src/ndhc.c +++ b/src/ndhc.c @@ -298,8 +298,7 @@ static void do_ndhc_work(void) pfds[5].fd = cs.listenFd; had_event = false; if (poll(pfds, 6, timeout) < 0) { - if (errno != EINTR) - suicide("poll failed"); + if (errno != EINTR) suicide("poll failed"); } bool sev_dhcp = false; @@ -524,8 +523,7 @@ static void wait_for_rfkill() for (;;) { pfds[0].fd = cs.rfkillFd; if (poll(pfds, 1, -1) < 0) { - if (errno == EINTR) continue; - else suicide("poll failed"); + if (errno != EINTR) suicide("poll failed"); } if (pfds[0].revents & POLLIN) { pfds[0].revents &= ~POLLIN; diff --git a/src/sockd.c b/src/sockd.c index 1861781..535ae7a 100644 --- a/src/sockd.c +++ b/src/sockd.c @@ -554,8 +554,7 @@ static void do_sockd_work(void) for (;;) { if (poll(pfds, 2, -1) < 0) { - if (errno == EINTR) continue; - else suicide("poll failed"); + if (errno != EINTR) suicide("poll failed"); } if (pfds[0].revents & POLLIN) { pfds[0].revents &= ~POLLIN;