From b2ac10e875921cbad299abc300fdaf6f3f3a14ed Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Tue, 9 Jan 2024 13:48:03 +0100 Subject: restart poll immediately on signal, we read the signal from selfpipe anyway --- nitro.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nitro.c b/nitro.c index c66c108..fc58a25 100644 --- a/nitro.c +++ b/nitro.c @@ -710,9 +710,6 @@ on_signal(int sig) int old_errno = errno; switch (sig) { - case SIGCHLD: - write(selfpipe[1], "", 1); - break; case SIGINT: if (real_pid1) want_reboot = 1; /* Linux Ctrl-Alt-Delete */ @@ -725,10 +722,13 @@ on_signal(int sig) case SIGHUP: want_rescan = 1; break; + case SIGCHLD: /* just selfpipe */ case SIGALRM: /* just for EINTR */ break; } + write(selfpipe[1], "", 1); + errno = old_errno; } @@ -1388,7 +1388,10 @@ main(int argc, char *argv[]) prn(1, "poll(timeout=%d)\n", timeout); fds[GLOG].fd = (log_format < 0) ? -1 : globallog[0]; - poll(fds, sizeof fds / sizeof fds[0], timeout); + int r = 0; + do { + r = poll(fds, sizeof fds / sizeof fds[0], timeout); + } while (r == -1 && errno == EINTR); if (fds[CHLD].revents & POLLIN) { char ch; -- cgit 1.4.1