Correct nfds argument to select()

In readch_timed, we were passing 1 as the number of fds. This is correct if
the fd is 0 (stdin) which it typically is; however this will fail if in_ is
not stdin. Switch to in_ + 1.
This commit is contained in:
ridiculousfish 2021-04-07 13:18:51 -07:00
parent 48b42c0255
commit 0dd24c8f74

View File

@ -218,7 +218,7 @@ char_event_t input_event_queue_t::readch_timed(bool dequeue_timeouts) {
FD_ZERO(&fds);
FD_SET(in_, &fds);
struct timeval tm = {wait_on_escape_ms / 1000, 1000 * (wait_on_escape_ms % 1000)};
if (select(1, &fds, nullptr, nullptr, &tm) > 0) {
if (select(in_ + 1, &fds, nullptr, nullptr, &tm) > 0) {
result = readch();
}
}