Commit a486b62b84f47c216ce7fd12eaacf6cc2acfaf74

Stefan Sperling 2021-05-18T13:17:12

ignore SIGWINCH while polling in the main process Avoids an error where tog(1) would exit with "poll: Interrupted system call" while the terminal window was being resized. ok millert

diff --git a/lib/privsep.c b/lib/privsep.c
index df3a4a1..9722912 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -22,6 +22,7 @@
 
 #include <ctype.h>
 #include <limits.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -59,12 +60,22 @@ static const struct got_error *
 poll_fd(int fd, int events, int timeout)
 {
 	struct pollfd pfd[1];
+	struct timespec ts;
+	sigset_t sigset;
 	int n;
 
 	pfd[0].fd = fd;
 	pfd[0].events = events;
 
-	n = poll(pfd, 1, timeout);
+	ts.tv_sec = timeout;
+	ts.tv_nsec = 0;
+
+	if (sigemptyset(&sigset) == -1)
+		return got_error_from_errno("sigemptyset");
+	if (sigaddset(&sigset, SIGWINCH) == -1)
+		return got_error_from_errno("sigaddset");
+
+	n = ppoll(pfd, 1, timeout == INFTIM ? NULL : &ts, &sigset);
 	if (n == -1)
 		return got_error_from_errno("poll");
 	if (n == 0)