sfeed_curses

[fork] sfeed (atom feed) reader
Log | Files | Refs | README | LICENSE

commit 73ff168596c7edf2714828b351285f91b4513140
parent 37c797b2371812e93577de4027ccf18491f4bedc
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri, 17 Jul 2020 13:18:47 +0200

readch: not all systems signal EINTR in select()

Use a time-out value of 250ms.
Noticed on HaikuOS.

For systems that do support it do not needlessly call draw() on a read
time-out.

Diffstat:
Msfeed_curses.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sfeed_curses.c b/sfeed_curses.c @@ -870,14 +870,20 @@ readch(void) { unsigned char b; fd_set readfds; + struct timeval tv; for (;;) { FD_ZERO(&readfds); FD_SET(0, &readfds); - if (select(1, &readfds, NULL, NULL, NULL) == -1) { + tv.tv_sec = 0; + tv.tv_usec = 250000; /* 250ms */ + switch (select(1, &readfds, NULL, NULL, &tv)) { + case -1: if (errno != EINTR) err(1, "select"); return -2; /* EINTR: like a signal */ + case 0: + return -3; /* time-out */ } switch (read(0, &b, 1)) { @@ -1919,6 +1925,8 @@ nextpage: event: if (ch == EOF) goto end; + else if (ch == -3 && sigstate == 0) + continue; /* just a time-out, nothing to do */ /* handle last signal */ switch (sigstate) {