Skip to content

Commit 7e0d711

Browse files
committed
daemon: use timeout for uninterruptible poll
The poll provided in compat/poll.c is not interrupted by receiving SIGCHLD. When using this poll emulation, use a timeout for cleaning up dead children in a timely manner. Signed-off-by: Kim Gybels <[email protected]>
1 parent 468165c commit 7e0d711

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

daemon.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ static void socksetup(struct string_list *listen_addr, int listen_port, struct s
11461146
static int service_loop(struct socketlist *socklist)
11471147
{
11481148
struct pollfd *pfd;
1149-
int i;
1149+
int poll_timeout = -1, i;
11501150

11511151
pfd = xcalloc(socklist->nr, sizeof(struct pollfd));
11521152

@@ -1158,11 +1158,16 @@ static int service_loop(struct socketlist *socklist)
11581158
signal(SIGCHLD, child_handler);
11591159

11601160
for (;;) {
1161-
int i;
1161+
int i, ret;
11621162

11631163
check_dead_children();
1164-
1165-
if (poll(pfd, socklist->nr, -1) < 0) {
1164+
#ifdef NO_POLL
1165+
poll_timeout = live_children ? 100 : -1;
1166+
#endif
1167+
ret = poll(pfd, socklist->nr, poll_timeout);
1168+
if (ret == 0)
1169+
continue;
1170+
if (ret < 0) {
11661171
if (errno != EINTR) {
11671172
logerror("Poll failed, resuming: %s",
11681173
strerror(errno));

0 commit comments

Comments
 (0)