about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2024-01-09 13:48:03 +0100
committerLeah Neukirchen <leah@vuxu.org>2024-01-09 16:14:46 +0100
commitb2ac10e875921cbad299abc300fdaf6f3f3a14ed (patch)
treeeea714a4837ce2cc991182d63899738b27955042
parentdfd9e40e6af48218641983f1b4181b90275c80bd (diff)
downloadnitro-b2ac10e875921cbad299abc300fdaf6f3f3a14ed.tar.gz
nitro-b2ac10e875921cbad299abc300fdaf6f3f3a14ed.tar.xz
nitro-b2ac10e875921cbad299abc300fdaf6f3f3a14ed.zip
restart poll immediately on signal, we read the signal from selfpipe anyway
-rw-r--r--nitro.c11
1 files 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;