diff options
| author | Maxime Coste <mawww@kakoune.org> | 2019-10-08 18:38:05 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-10-08 18:38:05 +1100 |
| commit | a2993ea104ca1d9a04fb01b163828b0a08ff95d9 (patch) | |
| tree | dc2f234f96d77bba1578479e48d5ea6b7f2bf11f /src | |
| parent | 2f1be14b5f4d3668df14f56239978e7e00102806 (diff) | |
Check that stdin is readable before calling read
This should not be necessary, but it works around a bug in WSL.
Fixes #3112
Diffstat (limited to 'src')
| -rw-r--r-- | src/ncurses_ui.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 3e1a4c6b..85785f9a 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -5,6 +5,7 @@ #include "keys.hh" #include "ranges.hh" #include "string_utils.hh" +#include "file.hh" #include <algorithm> @@ -579,7 +580,7 @@ Optional<Key> NCursesUI::get_next_key() static auto get_char = []() -> Optional<unsigned char> { unsigned char c = 0; - if (read(STDIN_FILENO, &c, 1) == 1) + if (fd_readable(STDIN_FILENO) and read(STDIN_FILENO, &c, 1) == 1) return c; return {}; }; |
