From 0f9a690eba9184c8f2c86e4a975612aff49cc9e8 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 8 Dec 2017 11:10:59 -0500 Subject: terminal-unix: fix busy looping on Linux POSIX permits select() to modify the timeout, which can happen on the Linux implementation. This can reset the timeout, which spins this into a tight loop. A timeout isn't necessary in the first place, so just use NULL instead. --- osdep/terminal-unix.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'osdep') diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c index c7309fbf50..c9f3553ff0 100644 --- a/osdep/terminal-unix.c +++ b/osdep/terminal-unix.c @@ -389,13 +389,12 @@ static void *terminal_thread(void *ptr) bool stdin_ok = read_terminal; // if false, we still wait for SIGTERM fd_set readfds; int max = death_pipe[0] > tty_in ? death_pipe[0] : tty_in; - struct timeval timeout = { .tv_sec = 0, .tv_usec = 100000 }; while (1) { FD_ZERO(&readfds); FD_SET(death_pipe[0], &readfds); FD_SET(tty_in, &readfds); getch2_poll(); - int s = select(max + 1, &readfds, NULL, NULL, &timeout); + int s = select(max + 1, &readfds, NULL, NULL, NULL); if (s == -1) { break; } else if (s != 0) { -- cgit v1.2.3