aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-04-05 15:11:07 +0100
committerRon Yorston <rmy@pobox.com>2018-04-05 15:11:07 +0100
commit91ee3425d1d39a86eb0a3460d9f14e57c24e0b83 (patch)
treeeb37c85c29da41e57ac9592e8b0e263d7def7479
parent33a914da6bba61e27aee82675276bf1dccc52966 (diff)
downloadbusybox-w32-91ee3425d1d39a86eb0a3460d9f14e57c24e0b83.tar.gz
busybox-w32-91ee3425d1d39a86eb0a3460d9f14e57c24e0b83.tar.bz2
busybox-w32-91ee3425d1d39a86eb0a3460d9f14e57c24e0b83.zip
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.
-rw-r--r--win32/termios.c8
1 files 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)
25 GetConsoleMode(cin, &mode); 25 GetConsoleMode(cin, &mode);
26 SetConsoleMode(cin, 0); 26 SetConsoleMode(cin, 0);
27 27
28 if (timeout > 0) {
29 if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0)
30 goto done;
31 }
32 while (1) { 28 while (1) {
29 if (timeout > 0) {
30 if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0)
31 goto done;
32 }
33 if (!ReadConsoleInput(cin, &record, 1, &nevent_out)) 33 if (!ReadConsoleInput(cin, &record, 1, &nevent_out))
34 goto done; 34 goto done;
35 if (record.EventType != KEY_EVENT || !record.Event.KeyEvent.bKeyDown) 35 if (record.EventType != KEY_EVENT || !record.Event.KeyEvent.bKeyDown)