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