Mercurial > emacs
changeset 22535:fd9324c5a498
(wait_reading_process_input): Recompute timeout each
time through the loop. Check requeued_events_pending_p and exit
the loop if there is unread keyboard input.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sun, 21 Jun 1998 14:52:08 +0000 |
parents | 442d61eaab83 |
children | e4bcb7cb0038 |
files | src/process.c |
diffstat | 1 files changed, 26 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/process.c Sun Jun 21 14:29:07 1998 +0000 +++ b/src/process.c Sun Jun 21 14:52:08 1998 +0000 @@ -4525,6 +4525,7 @@ Lisp_Object read_kbd; int do_display; { + register int nfds; EMACS_TIME end_time, timeout; SELECT_TYPE waitchannels; int xerrno; @@ -4540,27 +4541,17 @@ /* What does time_limit really mean? */ if (time_limit || microsecs) { - if (time_limit == -1) - /* In fact, it's zero. */ - EMACS_SET_SECS_USECS (timeout, 0, 0); - else - EMACS_SET_SECS_USECS (timeout, time_limit, microsecs); - - /* How far in the future is that? */ EMACS_GET_TIME (end_time); + EMACS_SET_SECS_USECS (timeout, time_limit, microsecs); EMACS_ADD_TIME (end_time, end_time, timeout); } - else - /* It's infinite. */ - EMACS_SET_SECS_USECS (timeout, 100000, 0); /* Turn off periodic alarms (in case they are in use) because the select emulator uses alarms. */ stop_polling (); - for (;;) + while (1) { - int nfds; int timeout_reduced_for_timers = 0; /* If calling from keyboard input, do not quit @@ -4575,13 +4566,25 @@ /* Compute time from now till when time limit is up */ /* Exit if already run out */ - if (time_limit > 0 || microsecs) + if (time_limit == -1) + { + /* -1 specified for timeout means + gobble output available now + but don't wait at all. */ + + EMACS_SET_SECS_USECS (timeout, 0, 0); + } + else if (time_limit || microsecs) { EMACS_GET_TIME (timeout); EMACS_SUB_TIME (timeout, end_time, timeout); if (EMACS_TIME_NEG_P (timeout)) break; } + else + { + EMACS_SET_SECS_USECS (timeout, 100000, 0); + } /* If our caller will not immediately handle keyboard events, run timer events directly. @@ -4603,6 +4606,11 @@ goto retry; } + /* If there is unread keyboard input, also return. */ + if (XINT (read_kbd) != 0 + && requeued_events_pending_p ()) + break; + if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1) { EMACS_TIME difference; @@ -4687,6 +4695,11 @@ break; } + /* If there is unread keyboard input, also return. */ + if (XINT (read_kbd) != 0 + && requeued_events_pending_p ()) + break; + /* If wait_for_cell. check for keyboard input but don't run any timers. ??? (It seems wrong to me to check for keyboard