From 91ee3425d1d39a86eb0a3460d9f14e57c24e0b83 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 5 Apr 2018 15:11:07 +0100 Subject: win32: ensure timeout works in read_key Move the wait for timeout into the while loop of read_key. Otherwise the timeout won't be checked after any event that doesn't result in a value being returned. --- win32/termios.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/win32/termios.c b/win32/termios.c index 658af4a26..a1329ceba 100644 --- a/win32/termios.c +++ b/win32/termios.c @@ -25,11 +25,11 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) GetConsoleMode(cin, &mode); SetConsoleMode(cin, 0); - if (timeout > 0) { - if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0) - goto done; - } while (1) { + if (timeout > 0) { + if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0) + goto done; + } if (!ReadConsoleInput(cin, &record, 1, &nevent_out)) goto done; if (record.EventType != KEY_EVENT || !record.Event.KeyEvent.bKeyDown) -- cgit v1.2.3-55-g6feb