Check that stdin is readable before calling read
This should not be necessary, but it works around a bug in WSL. Fixes #3112
This commit is contained in:
parent
2f1be14b5f
commit
a2993ea104
|
@ -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 {};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user