diff --git a/osdep/getch2.c b/osdep/getch2.c index 13eb47bc29..8b87e79c76 100644 --- a/osdep/getch2.c +++ b/osdep/getch2.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #ifdef HAVE_TERMIOS @@ -366,8 +367,10 @@ bool getch2(struct input_ctx *input_ctx) * happen if the terminal state change done in getch2_enable() * works. */ - if (retval < 1) - return retval; + if (retval == 0) + return false; + if (retval == -1) + return errno != EBADF && errno != EINVAL; getch2_len += retval; while (getch2_pos < getch2_len) {