From 728738553fb473e4ad9f2c4efc88e7e28fcda20d Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 22 Jan 2023 09:26:47 +0000 Subject: 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) --- win32/termios.c | 1 + 1 file changed, 1 insertion(+) 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) SetConsoleMode(cin, 0); while (1) { + errno = 0; if (timeout > 0) { if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0) goto done; -- cgit v1.2.3-55-g6feb