The poll provided in compat/poll.c is not interrupted by receiving
SIGCHLD. Use a timeout for cleaning up dead children in a timely manner.

Signed-off-by: Kim Gybels <kgyb...@infogroep.be>
---
 daemon.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/daemon.c b/daemon.c
index fe833ea7de..6dc95c1b2f 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1147,6 +1147,7 @@ static int service_loop(struct socketlist *socklist)
 {
        struct pollfd *pfd;
        int i;
+       int poll_timeout = -1;
 
        pfd = xcalloc(socklist->nr, sizeof(struct pollfd));
 
@@ -1161,8 +1162,13 @@ static int service_loop(struct socketlist *socklist)
                int i;
 
                check_dead_children();
-
-               if (poll(pfd, socklist->nr, -1) < 0) {
+#ifdef NO_POLL
+               poll_timeout = live_children ? 100 : -1;
+#endif
+               int ret = poll(pfd, socklist->nr, poll_timeout);
+               if  (ret == 0) {
+                       continue;
+               } else if (ret < 0) {
                        if (errno != EINTR) {
                                logerror("Poll failed, resuming: %s",
                                      strerror(errno));
-- 
2.17.0.windows.1

Reply via email to