From 5896ca8925b65d86a392269c0696c96755890b1a Mon Sep 17 00:00:00 2001 From: Ken Brown Date: Wed, 17 Nov 2021 11:55:39 -0500 Subject: [PATCH] Avoid delays waiting for input on systems without SIGIO * src/process.c (wait_reading_process_output) [!USABLE_SIGIO]: If we're waiting for input, don't use a timeout of more than 25 msec in the call to select. (Bug#50043) --- src/process.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/process.c b/src/process.c index f923aff1cb3..808bf6f1ff9 100644 --- a/src/process.c +++ b/src/process.c @@ -5588,6 +5588,15 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, timeout = make_timespec (0, 0); #endif +#ifndef USABLE_SIGIO + /* If we're polling for input, don't get stuck in select for + more than 25 msec. */ + struct timespec short_timeout = make_timespec (0, 25000000); + if ((read_kbd || !NILP (wait_for_cell)) + && timespec_cmp (short_timeout, timeout) < 0) + timeout = short_timeout; +#endif + /* Non-macOS HAVE_GLIB builds call thread_select in xgselect.c. */ #if defined HAVE_GLIB && !defined HAVE_NS nfds = xg_select (max_desc + 1, -- 2.39.2