commit a486b62b84f47c216ce7fd12eaacf6cc2acfaf74 from: Stefan Sperling date: Tue May 18 13:17:12 2021 UTC 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 commit - a3af57b852fbc7353bf13955b95da3b4eff19d62 commit + a486b62b84f47c216ce7fd12eaacf6cc2acfaf74 blob - df3a4a17cfe53a165183f57fb4a0eebe62acab91 blob + 97229123f0a5c6b797ce37122fe5960b948d80cc --- lib/privsep.c +++ lib/privsep.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -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)