diff options
author | Ron Yorston <rmy@pobox.com> | 2023-01-22 09:26:47 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-01-22 09:26:47 +0000 |
commit | 728738553fb473e4ad9f2c4efc88e7e28fcda20d (patch) | |
tree | 76378833b3ef3a4fd2f2c161c3bc9237d4f8d273 | |
parent | 4c92ce9e14703a3100f1aa9fd90bc3864d9e856b (diff) | |
download | busybox-w32-728738553fb473e4ad9f2c4efc88e7e28fcda20d.tar.gz busybox-w32-728738553fb473e4ad9f2c4efc88e7e28fcda20d.tar.bz2 busybox-w32-728738553fb473e4ad9f2c4efc88e7e28fcda20d.zip |
win32: reset errno in read_key()
The WIN32 implementation of read_key() didn't reset errno to zero,
unlike the upstream version. This could result in invalid non-zero
errno values after calls to lineedit_read_key().
For example, after an attempt to run a non-existent command in the
shell errno is set to ENOENT. If the shell had vi line edit mode
enabled any command that reads an additional character (e.g. 'c' or
'd') would see the non-zero errno and report EOF.
(GitHub issue #283)
-rw-r--r-- | win32/termios.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/win32/termios.c b/win32/termios.c index 45d4e7740..7d390ce09 100644 --- a/win32/termios.c +++ b/win32/termios.c | |||
@@ -21,6 +21,7 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) | |||
21 | SetConsoleMode(cin, 0); | 21 | SetConsoleMode(cin, 0); |
22 | 22 | ||
23 | while (1) { | 23 | while (1) { |
24 | errno = 0; | ||
24 | if (timeout > 0) { | 25 | if (timeout > 0) { |
25 | if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0) | 26 | if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0) |
26 | goto done; | 27 | goto done; |