From a2ea9a9035603f1971058a80afb1fad8fff63a26 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 3 Aug 2018 19:22:28 -0400 Subject: Continue on EINTR from poll Resizing the terminal causes it. --- chat.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chat.c b/chat.c index 497c051..d616b91 100644 --- a/chat.c +++ b/chat.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -518,10 +519,13 @@ int main(int argc, char *argv[]) { { .fd = STDIN_FILENO, .events = POLLIN }, { .fd = client.sock, .events = POLLIN }, }; - while (0 < poll(fds, 2, -1)) { + for (;;) { + int nfds = poll(fds, 2, -1); + if (nfds < 0 && errno == EINTR) continue; + if (nfds < 0) err(EX_IOERR, "poll"); + if (fds[0].revents) uiRead(); if (fds[1].revents) clientRead(); uiDraw(); } - err(EX_IOERR, "poll"); } -- cgit 1.4.1-2-gfad0