3719 |
} |
} |
3720 |
|
|
3721 |
DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, |
DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, |
3722 |
0, 3, 0, |
0, 4, 0, |
3723 |
doc: /* Allow any pending output from subprocesses to be read by Emacs. |
doc: /* Allow any pending output from subprocesses to be read by Emacs. |
3724 |
It is read into the process' buffers or given to their filter functions. |
It is read into the process' buffers or given to their filter functions. |
3725 |
Non-nil arg PROCESS means do not return until some output has been received |
Non-nil arg PROCESS means do not return until some output has been received |
3727 |
Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of |
Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of |
3728 |
seconds and microseconds to wait; return after that much time whether |
seconds and microseconds to wait; return after that much time whether |
3729 |
or not there is input. |
or not there is input. |
3730 |
|
If optional fourth arg JUST-THIS-ONE is non-nil, only accept output |
3731 |
|
from PROCESS, suspending reading output from other processes. |
3732 |
|
If JUST-THIS-ONE is an integer, don't run any timers either. |
3733 |
Return non-nil iff we received any output before the timeout expired. */) |
Return non-nil iff we received any output before the timeout expired. */) |
3734 |
(process, timeout, timeout_msecs) |
(process, timeout, timeout_msecs, just_this_one) |
3735 |
register Lisp_Object process, timeout, timeout_msecs; |
register Lisp_Object process, timeout, timeout_msecs, just_this_one; |
3736 |
{ |
{ |
3737 |
int seconds; |
int seconds; |
3738 |
int useconds; |
int useconds; |
3739 |
|
|
3740 |
if (! NILP (process)) |
if (! NILP (process)) |
3741 |
CHECK_PROCESS (process); |
CHECK_PROCESS (process); |
3742 |
|
else |
3743 |
|
just_this_one = Qnil; |
3744 |
|
|
3745 |
if (! NILP (timeout_msecs)) |
if (! NILP (timeout_msecs)) |
3746 |
{ |
{ |
3778 |
else |
else |
3779 |
seconds = NILP (process) ? -1 : 0; |
seconds = NILP (process) ? -1 : 0; |
3780 |
|
|
|
if (NILP (process)) |
|
|
XSETFASTINT (process, 0); |
|
|
|
|
3781 |
return |
return |
3782 |
(wait_reading_process_input (seconds, useconds, process, 0) |
(wait_reading_process_output (seconds, useconds, 0, 0, |
3783 |
|
Qnil, |
3784 |
|
!NILP (process) ? XPROCESS (process) : NULL, |
3785 |
|
NILP (just_this_one) ? 0 : |
3786 |
|
!INTEGERP (just_this_one) ? 1 : -1) |
3787 |
? Qt : Qnil); |
? Qt : Qnil); |
3788 |
} |
} |
3789 |
|
|
3983 |
lisp code is being evalled. |
lisp code is being evalled. |
3984 |
This is also used in record_asynch_buffer_change. |
This is also used in record_asynch_buffer_change. |
3985 |
For that purpose, this must be 0 |
For that purpose, this must be 0 |
3986 |
when not inside wait_reading_process_input. */ |
when not inside wait_reading_process_output. */ |
3987 |
static int waiting_for_user_input_p; |
static int waiting_for_user_input_p; |
3988 |
|
|
3989 |
/* This is here so breakpoints can be put on it. */ |
/* This is here so breakpoints can be put on it. */ |
3990 |
static void |
static void |
3991 |
wait_reading_process_input_1 () |
wait_reading_process_output_1 () |
3992 |
{ |
{ |
3993 |
} |
} |
3994 |
|
|
4010 |
1 to return when input is available, or |
1 to return when input is available, or |
4011 |
-1 meaning caller will actually read the input, so don't throw to |
-1 meaning caller will actually read the input, so don't throw to |
4012 |
the quit handler, or |
the quit handler, or |
|
a cons cell, meaning wait until its car is non-nil |
|
|
(and gobble terminal input into the buffer if any arrives), or |
|
|
a process object, meaning wait until something arrives from that |
|
|
process. The return value is true iff we read some input from |
|
|
that process. |
|
4013 |
|
|
4014 |
DO_DISPLAY != 0 means redisplay should be done to show subprocess |
DO_DISPLAY != 0 means redisplay should be done to show subprocess |
4015 |
output that arrives. |
output that arrives. |
4016 |
|
|
4017 |
|
If WAIT_FOR_CELL is a cons cell, wait until its car is non-nil |
4018 |
|
(and gobble terminal input into the buffer if any arrives). |
4019 |
|
|
4020 |
If READ_KBD is a pointer to a struct Lisp_Process, then the |
If WAIT_PROC is specified, wait until something arrives from that |
4021 |
function returns true iff we received input from that process |
process. The return value is true iff we read some input from |
4022 |
before the timeout elapsed. |
that process. |
4023 |
|
|
4024 |
|
If JUST_WAIT_PROC is non-nil, handle only output from WAIT_PROC |
4025 |
|
(suspending output from other processes). A negative value |
4026 |
|
means don't run any timers either. |
4027 |
|
|
4028 |
|
If WAIT_PROC is specified, then the function returns true iff we |
4029 |
|
received input from that process before the timeout elapsed. |
4030 |
Otherwise, return true iff we received input from any process. */ |
Otherwise, return true iff we received input from any process. */ |
4031 |
|
|
4032 |
int |
int |
4033 |
wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) |
wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, |
4034 |
int time_limit, microsecs; |
wait_for_cell, wait_proc, just_wait_proc) |
4035 |
Lisp_Object read_kbd; |
int time_limit, microsecs, read_kbd, do_display; |
4036 |
int do_display; |
Lisp_Object wait_for_cell; |
4037 |
|
struct Lisp_Process *wait_proc; |
4038 |
|
int just_wait_proc; |
4039 |
{ |
{ |
4040 |
register int channel, nfds; |
register int channel, nfds; |
4041 |
SELECT_TYPE Available; |
SELECT_TYPE Available; |
4045 |
Lisp_Object proc; |
Lisp_Object proc; |
4046 |
EMACS_TIME timeout, end_time; |
EMACS_TIME timeout, end_time; |
4047 |
int wait_channel = -1; |
int wait_channel = -1; |
|
struct Lisp_Process *wait_proc = 0; |
|
4048 |
int got_some_input = 0; |
int got_some_input = 0; |
4049 |
/* Either nil or a cons cell, the car of which is of interest and |
/* Either nil or a cons cell, the car of which is of interest and |
4050 |
may be changed outside of this routine. */ |
may be changed outside of this routine. */ |
|
Lisp_Object wait_for_cell = Qnil; |
|
4051 |
int saved_waiting_for_user_input_p = waiting_for_user_input_p; |
int saved_waiting_for_user_input_p = waiting_for_user_input_p; |
4052 |
|
|
4053 |
FD_ZERO (&Available); |
FD_ZERO (&Available); |
4054 |
FD_ZERO (&Connecting); |
FD_ZERO (&Connecting); |
4055 |
|
|
4056 |
/* If read_kbd is a process to watch, set wait_proc and wait_channel |
/* If wait_proc is a process to watch, set wait_channel accordingly. */ |
4057 |
accordingly. */ |
if (wait_proc != NULL) |
4058 |
if (PROCESSP (read_kbd)) |
wait_channel = XINT (wait_proc->infd); |
|
{ |
|
|
wait_proc = XPROCESS (read_kbd); |
|
|
wait_channel = XINT (wait_proc->infd); |
|
|
XSETFASTINT (read_kbd, 0); |
|
|
} |
|
|
|
|
|
/* If waiting for non-nil in a cell, record where. */ |
|
|
if (CONSP (read_kbd)) |
|
|
{ |
|
|
wait_for_cell = read_kbd; |
|
|
XSETFASTINT (read_kbd, 0); |
|
|
} |
|
4059 |
|
|
4060 |
waiting_for_user_input_p = XINT (read_kbd); |
waiting_for_user_input_p = read_kbd; |
4061 |
|
|
4062 |
/* Since we may need to wait several times, |
/* Since we may need to wait several times, |
4063 |
compute the absolute time to return at. */ |
compute the absolute time to return at. */ |
4085 |
/* If calling from keyboard input, do not quit |
/* If calling from keyboard input, do not quit |
4086 |
since we want to return C-g as an input character. |
since we want to return C-g as an input character. |
4087 |
Otherwise, do pending quit if requested. */ |
Otherwise, do pending quit if requested. */ |
4088 |
if (XINT (read_kbd) >= 0) |
if (read_kbd >= 0) |
4089 |
QUIT; |
QUIT; |
4090 |
#ifdef SYNC_INPUT |
#ifdef SYNC_INPUT |
4091 |
else if (interrupt_input_pending) |
else if (interrupt_input_pending) |
4122 |
But not if wait_for_cell; in those cases, |
But not if wait_for_cell; in those cases, |
4123 |
the wait is supposed to be short, |
the wait is supposed to be short, |
4124 |
and those callers cannot handle running arbitrary Lisp code here. */ |
and those callers cannot handle running arbitrary Lisp code here. */ |
4125 |
if (NILP (wait_for_cell)) |
if (NILP (wait_for_cell) |
4126 |
|
&& just_wait_proc >= 0) |
4127 |
{ |
{ |
4128 |
EMACS_TIME timer_delay; |
EMACS_TIME timer_delay; |
4129 |
|
|
4151 |
while (!detect_input_pending ()); |
while (!detect_input_pending ()); |
4152 |
|
|
4153 |
/* If there is unread keyboard input, also return. */ |
/* If there is unread keyboard input, also return. */ |
4154 |
if (XINT (read_kbd) != 0 |
if (read_kbd != 0 |
4155 |
&& requeued_events_pending_p ()) |
&& requeued_events_pending_p ()) |
4156 |
break; |
break; |
4157 |
|
|
4169 |
else if (time_limit != -1) |
else if (time_limit != -1) |
4170 |
{ |
{ |
4171 |
/* This is so a breakpoint can be put here. */ |
/* This is so a breakpoint can be put here. */ |
4172 |
wait_reading_process_input_1 (); |
wait_reading_process_output_1 (); |
4173 |
} |
} |
4174 |
} |
} |
4175 |
|
|
4179 |
It is important that we do this before checking for process |
It is important that we do this before checking for process |
4180 |
activity. If we get a SIGCHLD after the explicit checks for |
activity. If we get a SIGCHLD after the explicit checks for |
4181 |
process activity, timeout is the only way we will know. */ |
process activity, timeout is the only way we will know. */ |
4182 |
if (XINT (read_kbd) < 0) |
if (read_kbd < 0) |
4183 |
set_waiting_for_input (&timeout); |
set_waiting_for_input (&timeout); |
4184 |
|
|
4185 |
/* If status of something has changed, and no input is |
/* If status of something has changed, and no input is |
4259 |
|
|
4260 |
/* Wait till there is something to do */ |
/* Wait till there is something to do */ |
4261 |
|
|
4262 |
if (!NILP (wait_for_cell)) |
if (wait_proc && just_wait_proc) |
4263 |
|
{ |
4264 |
|
if (XINT (wait_proc->infd) < 0) /* Terminated */ |
4265 |
|
break; |
4266 |
|
FD_SET (XINT (wait_proc->infd), &Available); |
4267 |
|
check_connect = check_delay = 0; |
4268 |
|
} |
4269 |
|
else if (!NILP (wait_for_cell)) |
4270 |
{ |
{ |
4271 |
Available = non_process_wait_mask; |
Available = non_process_wait_mask; |
4272 |
check_connect = check_delay = 0; |
check_connect = check_delay = 0; |
4273 |
} |
} |
4274 |
else |
else |
4275 |
{ |
{ |
4276 |
if (! XINT (read_kbd)) |
if (! read_kbd) |
4277 |
Available = non_keyboard_wait_mask; |
Available = non_keyboard_wait_mask; |
4278 |
else |
else |
4279 |
Available = input_wait_mask; |
Available = input_wait_mask; |
4290 |
{ |
{ |
4291 |
clear_waiting_for_input (); |
clear_waiting_for_input (); |
4292 |
redisplay_preserve_echo_area (11); |
redisplay_preserve_echo_area (11); |
4293 |
if (XINT (read_kbd) < 0) |
if (read_kbd < 0) |
4294 |
set_waiting_for_input (&timeout); |
set_waiting_for_input (&timeout); |
4295 |
} |
} |
4296 |
|
|
4297 |
no_avail = 0; |
no_avail = 0; |
4298 |
if (XINT (read_kbd) && detect_input_pending ()) |
if (read_kbd && detect_input_pending ()) |
4299 |
{ |
{ |
4300 |
nfds = 0; |
nfds = 0; |
4301 |
no_avail = 1; |
no_avail = 1; |
4412 |
/* If we are using polling for input, |
/* If we are using polling for input, |
4413 |
and we see input available, make it get read now. |
and we see input available, make it get read now. |
4414 |
Otherwise it might not actually get read for a second. |
Otherwise it might not actually get read for a second. |
4415 |
And on hpux, since we turn off polling in wait_reading_process_input, |
And on hpux, since we turn off polling in wait_reading_process_output, |
4416 |
it might never get read at all if we don't spend much time |
it might never get read at all if we don't spend much time |
4417 |
outside of wait_reading_process_input. */ |
outside of wait_reading_process_output. */ |
4418 |
if (XINT (read_kbd) && interrupt_input |
if (read_kbd && interrupt_input |
4419 |
&& keyboard_bit_set (&Available) |
&& keyboard_bit_set (&Available) |
4420 |
&& input_polling_used ()) |
&& input_polling_used ()) |
4421 |
kill (getpid (), SIGALRM); |
kill (getpid (), SIGALRM); |
4425 |
/* If there is any, return immediately |
/* If there is any, return immediately |
4426 |
to give it higher priority than subprocesses */ |
to give it higher priority than subprocesses */ |
4427 |
|
|
4428 |
if (XINT (read_kbd) != 0) |
if (read_kbd != 0) |
4429 |
{ |
{ |
4430 |
int old_timers_run = timers_run; |
int old_timers_run = timers_run; |
4431 |
struct buffer *old_buffer = current_buffer; |
struct buffer *old_buffer = current_buffer; |
4450 |
} |
} |
4451 |
|
|
4452 |
/* If there is unread keyboard input, also return. */ |
/* If there is unread keyboard input, also return. */ |
4453 |
if (XINT (read_kbd) != 0 |
if (read_kbd != 0 |
4454 |
&& requeued_events_pending_p ()) |
&& requeued_events_pending_p ()) |
4455 |
break; |
break; |
4456 |
|
|
4461 |
That would causes delays in pasting selections, for example. |
That would causes delays in pasting selections, for example. |
4462 |
|
|
4463 |
(We used to do this only if wait_for_cell.) */ |
(We used to do this only if wait_for_cell.) */ |
4464 |
if (XINT (read_kbd) == 0 && detect_input_pending ()) |
if (read_kbd == 0 && detect_input_pending ()) |
4465 |
{ |
{ |
4466 |
swallow_events (do_display); |
swallow_events (do_display); |
4467 |
#if 0 /* Exiting when read_kbd doesn't request that seems wrong, though. */ |
#if 0 /* Exiting when read_kbd doesn't request that seems wrong, though. */ |
4480 |
In that case, there really is no input and no SIGIO, |
In that case, there really is no input and no SIGIO, |
4481 |
but select says there is input. */ |
but select says there is input. */ |
4482 |
|
|
4483 |
if (XINT (read_kbd) && interrupt_input |
if (read_kbd && interrupt_input |
4484 |
&& keyboard_bit_set (&Available) && ! noninteractive) |
&& keyboard_bit_set (&Available) && ! noninteractive) |
4485 |
kill (getpid (), SIGIO); |
kill (getpid (), SIGIO); |
4486 |
#endif |
#endif |
4490 |
|
|
4491 |
/* If checking input just got us a size-change event from X, |
/* If checking input just got us a size-change event from X, |
4492 |
obey it now if we should. */ |
obey it now if we should. */ |
4493 |
if (XINT (read_kbd) || ! NILP (wait_for_cell)) |
if (read_kbd || ! NILP (wait_for_cell)) |
4494 |
do_pending_window_change (0); |
do_pending_window_change (0); |
4495 |
|
|
4496 |
/* Check for data from a process. */ |
/* Check for data from a process. */ |
4665 |
/* If calling from keyboard input, do not quit |
/* If calling from keyboard input, do not quit |
4666 |
since we want to return C-g as an input character. |
since we want to return C-g as an input character. |
4667 |
Otherwise, do pending quit if requested. */ |
Otherwise, do pending quit if requested. */ |
4668 |
if (XINT (read_kbd) >= 0) |
if (read_kbd >= 0) |
4669 |
{ |
{ |
4670 |
/* Prevent input_pending from remaining set if we quit. */ |
/* Prevent input_pending from remaining set if we quit. */ |
4671 |
clear_input_pending (); |
clear_input_pending (); |
5310 |
that may allow the program |
that may allow the program |
5311 |
to finish doing output and read more. */ |
to finish doing output and read more. */ |
5312 |
{ |
{ |
|
Lisp_Object zero; |
|
5313 |
int offset = 0; |
int offset = 0; |
5314 |
|
|
5315 |
#ifdef BROKEN_PTY_READ_AFTER_EAGAIN |
#ifdef BROKEN_PTY_READ_AFTER_EAGAIN |
5344 |
else if (STRINGP (object)) |
else if (STRINGP (object)) |
5345 |
offset = buf - SDATA (object); |
offset = buf - SDATA (object); |
5346 |
|
|
|
XSETFASTINT (zero, 0); |
|
5347 |
#ifdef EMACS_HAS_USECS |
#ifdef EMACS_HAS_USECS |
5348 |
wait_reading_process_input (0, 20000, zero, 0); |
wait_reading_process_output (0, 20000, 0, 0, Qnil, NULL, 0); |
5349 |
#else |
#else |
5350 |
wait_reading_process_input (1, 0, zero, 0); |
wait_reading_process_output (1, 0, 0, 0, Qnil, NULL, 0); |
5351 |
#endif |
#endif |
5352 |
|
|
5353 |
if (BUFFERP (object)) |
if (BUFFERP (object)) |
5553 |
work. If the system has it, use it. */ |
work. If the system has it, use it. */ |
5554 |
#ifdef HAVE_TERMIOS |
#ifdef HAVE_TERMIOS |
5555 |
struct termios t; |
struct termios t; |
5556 |
|
cc_t *sig_char = NULL; |
5557 |
|
|
5558 |
|
tcgetattr (XINT (p->infd), &t); |
5559 |
|
|
5560 |
switch (signo) |
switch (signo) |
5561 |
{ |
{ |
5562 |
case SIGINT: |
case SIGINT: |
5563 |
tcgetattr (XINT (p->infd), &t); |
sig_char = &t.c_cc[VINTR]; |
5564 |
send_process (proc, &t.c_cc[VINTR], 1, Qnil); |
break; |
|
return; |
|
5565 |
|
|
5566 |
case SIGQUIT: |
case SIGQUIT: |
5567 |
tcgetattr (XINT (p->infd), &t); |
sig_char = &t.c_cc[VQUIT]; |
5568 |
send_process (proc, &t.c_cc[VQUIT], 1, Qnil); |
break; |
|
return; |
|
5569 |
|
|
5570 |
case SIGTSTP: |
case SIGTSTP: |
|
tcgetattr (XINT (p->infd), &t); |
|
5571 |
#if defined (VSWTCH) && !defined (PREFER_VSUSP) |
#if defined (VSWTCH) && !defined (PREFER_VSUSP) |
5572 |
send_process (proc, &t.c_cc[VSWTCH], 1, Qnil); |
sig_char = &t.c_cc[VSWTCH]; |
5573 |
#else |
#else |
5574 |
send_process (proc, &t.c_cc[VSUSP], 1, Qnil); |
sig_char = &t.c_cc[VSUSP]; |
5575 |
#endif |
#endif |
5576 |
return; |
break; |
5577 |
} |
} |
5578 |
|
|
5579 |
|
if (sig_char && *sig_char != CDISABLE) |
5580 |
|
{ |
5581 |
|
send_process (proc, sig_char, 1, Qnil); |
5582 |
|
return; |
5583 |
|
} |
5584 |
|
/* If we can't send the signal with a character, |
5585 |
|
fall through and send it another way. */ |
5586 |
#else /* ! HAVE_TERMIOS */ |
#else /* ! HAVE_TERMIOS */ |
5587 |
|
|
5588 |
/* On Berkeley descendants, the following IOCTL's retrieve the |
/* On Berkeley descendants, the following IOCTL's retrieve the |
5639 |
you'd better be using one of the alternatives above! */ |
you'd better be using one of the alternatives above! */ |
5640 |
#endif /* ! defined (TCGETA) */ |
#endif /* ! defined (TCGETA) */ |
5641 |
#endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */ |
#endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */ |
5642 |
#endif /* ! defined HAVE_TERMIOS */ |
/* In this case, the code above should alway returns. */ |
5643 |
abort (); |
abort (); |
5644 |
/* The code above always returns from the function. */ |
#endif /* ! defined HAVE_TERMIOS */ |
5645 |
|
|
5646 |
|
/* The code above may fall through if it can't |
5647 |
|
handle the signal. */ |
5648 |
#endif /* defined (SIGNALS_VIA_CHARACTERS) */ |
#endif /* defined (SIGNALS_VIA_CHARACTERS) */ |
5649 |
|
|
5650 |
#ifdef TIOCGPGRP |
#ifdef TIOCGPGRP |
6216 |
FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); |
FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); |
6217 |
} |
} |
6218 |
|
|
6219 |
/* Tell wait_reading_process_input that it needs to wake up and |
/* Tell wait_reading_process_output that it needs to wake up and |
6220 |
look around. */ |
look around. */ |
6221 |
if (input_available_clear_time) |
if (input_available_clear_time) |
6222 |
EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); |
EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); |
6234 |
else if (WIFSIGNALED (w)) |
else if (WIFSIGNALED (w)) |
6235 |
synch_process_termsig = WTERMSIG (w); |
synch_process_termsig = WTERMSIG (w); |
6236 |
|
|
6237 |
/* Tell wait_reading_process_input that it needs to wake up and |
/* Tell wait_reading_process_output that it needs to wake up and |
6238 |
look around. */ |
look around. */ |
6239 |
if (input_available_clear_time) |
if (input_available_clear_time) |
6240 |
EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); |
EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); |
6876 |
1 to return when input is available, or |
1 to return when input is available, or |
6877 |
-1 means caller will actually read the input, so don't throw to |
-1 means caller will actually read the input, so don't throw to |
6878 |
the quit handler. |
the quit handler. |
6879 |
a cons cell, meaning wait until its car is non-nil |
|
6880 |
(and gobble terminal input into the buffer if any arrives), or |
see full version for other parameters. We know that wait_proc will |
6881 |
We know that read_kbd will never be a Lisp_Process, since |
always be NULL, since `subprocesses' isn't defined. |
|
`subprocesses' isn't defined. |
|
6882 |
|
|
6883 |
do_display != 0 means redisplay should be done to show subprocess |
do_display != 0 means redisplay should be done to show subprocess |
6884 |
output that arrives. |
output that arrives. |
6886 |
Return true iff we received input from any process. */ |
Return true iff we received input from any process. */ |
6887 |
|
|
6888 |
int |
int |
6889 |
wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) |
wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, |
6890 |
int time_limit, microsecs; |
wait_for_cell, wait_proc, just_wait_proc) |
6891 |
Lisp_Object read_kbd; |
int time_limit, microsecs, read_kbd, do_display; |
6892 |
int do_display; |
Lisp_Object wait_for_cell; |
6893 |
|
struct Lisp_Process *wait_proc; |
6894 |
|
int just_wait_proc; |
6895 |
{ |
{ |
6896 |
register int nfds; |
register int nfds; |
6897 |
EMACS_TIME end_time, timeout; |
EMACS_TIME end_time, timeout; |
6898 |
SELECT_TYPE waitchannels; |
SELECT_TYPE waitchannels; |
6899 |
int xerrno; |
int xerrno; |
|
/* Either nil or a cons cell, the car of which is of interest and |
|
|
may be changed outside of this routine. */ |
|
|
Lisp_Object wait_for_cell; |
|
|
|
|
|
wait_for_cell = Qnil; |
|
|
|
|
|
/* If waiting for non-nil in a cell, record where. */ |
|
|
if (CONSP (read_kbd)) |
|
|
{ |
|
|
wait_for_cell = read_kbd; |
|
|
XSETFASTINT (read_kbd, 0); |
|
|
} |
|
6900 |
|
|
6901 |
/* What does time_limit really mean? */ |
/* What does time_limit really mean? */ |
6902 |
if (time_limit || microsecs) |
if (time_limit || microsecs) |
6919 |
/* If calling from keyboard input, do not quit |
/* If calling from keyboard input, do not quit |
6920 |
since we want to return C-g as an input character. |
since we want to return C-g as an input character. |
6921 |
Otherwise, do pending quit if requested. */ |
Otherwise, do pending quit if requested. */ |
6922 |
if (XINT (read_kbd) >= 0) |
if (read_kbd >= 0) |
6923 |
QUIT; |
QUIT; |
6924 |
|
|
6925 |
/* Exit now if the cell we're waiting for became non-nil. */ |
/* Exit now if the cell we're waiting for became non-nil. */ |
6970 |
while (!detect_input_pending ()); |
while (!detect_input_pending ()); |
6971 |
|
|
6972 |
/* If there is unread keyboard input, also return. */ |
/* If there is unread keyboard input, also return. */ |
6973 |
if (XINT (read_kbd) != 0 |
if (read_kbd != 0 |
6974 |
&& requeued_events_pending_p ()) |
&& requeued_events_pending_p ()) |
6975 |
break; |
break; |
6976 |
|
|
6988 |
|
|
6989 |
/* Cause C-g and alarm signals to take immediate action, |
/* Cause C-g and alarm signals to take immediate action, |
6990 |
and cause input available signals to zero out timeout. */ |
and cause input available signals to zero out timeout. */ |
6991 |
if (XINT (read_kbd) < 0) |
if (read_kbd < 0) |
6992 |
set_waiting_for_input (&timeout); |
set_waiting_for_input (&timeout); |
6993 |
|
|
6994 |
/* Wait till there is something to do. */ |
/* Wait till there is something to do. */ |
6995 |
|
|
6996 |
if (! XINT (read_kbd) && NILP (wait_for_cell)) |
if (! read_kbd && NILP (wait_for_cell)) |
6997 |
FD_ZERO (&waitchannels); |
FD_ZERO (&waitchannels); |
6998 |
else |
else |
6999 |
FD_SET (0, &waitchannels); |
FD_SET (0, &waitchannels); |
7004 |
{ |
{ |
7005 |
clear_waiting_for_input (); |
clear_waiting_for_input (); |
7006 |
redisplay_preserve_echo_area (15); |
redisplay_preserve_echo_area (15); |
7007 |
if (XINT (read_kbd) < 0) |
if (read_kbd < 0) |
7008 |
set_waiting_for_input (&timeout); |
set_waiting_for_input (&timeout); |
7009 |
} |
} |
7010 |
|
|
7011 |
if (XINT (read_kbd) && detect_input_pending ()) |
if (read_kbd && detect_input_pending ()) |
7012 |
{ |
{ |
7013 |
nfds = 0; |
nfds = 0; |
7014 |
FD_ZERO (&waitchannels); |
FD_ZERO (&waitchannels); |
7044 |
kill (getpid (), SIGIO); |
kill (getpid (), SIGIO); |
7045 |
#endif |
#endif |
7046 |
#ifdef SIGIO |
#ifdef SIGIO |
7047 |
if (XINT (read_kbd) && interrupt_input && (waitchannels & 1)) |
if (read_kbd && interrupt_input && (waitchannels & 1)) |
7048 |
kill (getpid (), SIGIO); |
kill (getpid (), SIGIO); |
7049 |
#endif |
#endif |
7050 |
|
|
7051 |
/* Check for keyboard input */ |
/* Check for keyboard input */ |
7052 |
|
|
7053 |
if ((XINT (read_kbd) != 0) |
if (read_kbd |
7054 |
&& detect_input_pending_run_timers (do_display)) |
&& detect_input_pending_run_timers (do_display)) |
7055 |
{ |
{ |
7056 |
swallow_events (do_display); |
swallow_events (do_display); |
7059 |
} |
} |
7060 |
|
|
7061 |
/* If there is unread keyboard input, also return. */ |
/* If there is unread keyboard input, also return. */ |
7062 |
if (XINT (read_kbd) != 0 |
if (read_kbd |
7063 |
&& requeued_events_pending_p ()) |
&& requeued_events_pending_p ()) |
7064 |
break; |
break; |
7065 |
|
|