diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 214 |
1 files changed, 109 insertions, 105 deletions
diff --git a/src/process.c b/src/process.c index 24ec816a699..688f97dc199 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -3719,7 +3719,7 @@ close_process_descs () | |||
| 3719 | } | 3719 | } |
| 3720 | 3720 | ||
| 3721 | DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, | 3721 | DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, |
| 3722 | 0, 3, 0, | 3722 | 0, 4, 0, |
| 3723 | doc: /* Allow any pending output from subprocesses to be read by Emacs. | 3723 | 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. | 3724 | 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 | 3725 | Non-nil arg PROCESS means do not return until some output has been received |
| @@ -3727,15 +3727,20 @@ from PROCESS. | |||
| 3727 | Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of | 3727 | 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 | 3728 | seconds and microseconds to wait; return after that much time whether |
| 3729 | or not there is input. | 3729 | 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. | ||
| 3730 | Return non-nil iff we received any output before the timeout expired. */) | 3733 | Return non-nil iff we received any output before the timeout expired. */) |
| 3731 | (process, timeout, timeout_msecs) | 3734 | (process, timeout, timeout_msecs, just_this_one) |
| 3732 | register Lisp_Object process, timeout, timeout_msecs; | 3735 | register Lisp_Object process, timeout, timeout_msecs, just_this_one; |
| 3733 | { | 3736 | { |
| 3734 | int seconds; | 3737 | int seconds; |
| 3735 | int useconds; | 3738 | int useconds; |
| 3736 | 3739 | ||
| 3737 | if (! NILP (process)) | 3740 | if (! NILP (process)) |
| 3738 | CHECK_PROCESS (process); | 3741 | CHECK_PROCESS (process); |
| 3742 | else | ||
| 3743 | just_this_one = Qnil; | ||
| 3739 | 3744 | ||
| 3740 | if (! NILP (timeout_msecs)) | 3745 | if (! NILP (timeout_msecs)) |
| 3741 | { | 3746 | { |
| @@ -3773,11 +3778,12 @@ Return non-nil iff we received any output before the timeout expired. */) | |||
| 3773 | else | 3778 | else |
| 3774 | seconds = NILP (process) ? -1 : 0; | 3779 | seconds = NILP (process) ? -1 : 0; |
| 3775 | 3780 | ||
| 3776 | if (NILP (process)) | ||
| 3777 | XSETFASTINT (process, 0); | ||
| 3778 | |||
| 3779 | return | 3781 | return |
| 3780 | (wait_reading_process_input (seconds, useconds, process, 0) | 3782 | (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) | ||
| 3781 | ? Qt : Qnil); | 3787 | ? Qt : Qnil); |
| 3782 | } | 3788 | } |
| 3783 | 3789 | ||
| @@ -3977,12 +3983,12 @@ server_accept_connection (server, channel) | |||
| 3977 | lisp code is being evalled. | 3983 | lisp code is being evalled. |
| 3978 | This is also used in record_asynch_buffer_change. | 3984 | This is also used in record_asynch_buffer_change. |
| 3979 | For that purpose, this must be 0 | 3985 | For that purpose, this must be 0 |
| 3980 | when not inside wait_reading_process_input. */ | 3986 | when not inside wait_reading_process_output. */ |
| 3981 | static int waiting_for_user_input_p; | 3987 | static int waiting_for_user_input_p; |
| 3982 | 3988 | ||
| 3983 | /* This is here so breakpoints can be put on it. */ | 3989 | /* This is here so breakpoints can be put on it. */ |
| 3984 | static void | 3990 | static void |
| 3985 | wait_reading_process_input_1 () | 3991 | wait_reading_process_output_1 () |
| 3986 | { | 3992 | { |
| 3987 | } | 3993 | } |
| 3988 | 3994 | ||
| @@ -4004,25 +4010,32 @@ wait_reading_process_input_1 () | |||
| 4004 | 1 to return when input is available, or | 4010 | 1 to return when input is available, or |
| 4005 | -1 meaning caller will actually read the input, so don't throw to | 4011 | -1 meaning caller will actually read the input, so don't throw to |
| 4006 | the quit handler, or | 4012 | the quit handler, or |
| 4007 | a cons cell, meaning wait until its car is non-nil | ||
| 4008 | (and gobble terminal input into the buffer if any arrives), or | ||
| 4009 | a process object, meaning wait until something arrives from that | ||
| 4010 | process. The return value is true iff we read some input from | ||
| 4011 | that process. | ||
| 4012 | 4013 | ||
| 4013 | DO_DISPLAY != 0 means redisplay should be done to show subprocess | 4014 | DO_DISPLAY != 0 means redisplay should be done to show subprocess |
| 4014 | output that arrives. | 4015 | 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). | ||
| 4015 | 4019 | ||
| 4016 | If READ_KBD is a pointer to a struct Lisp_Process, then the | 4020 | If WAIT_PROC is specified, wait until something arrives from that |
| 4017 | function returns true iff we received input from that process | 4021 | process. The return value is true iff we read some input from |
| 4018 | before the timeout elapsed. | 4022 | 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. | ||
| 4019 | Otherwise, return true iff we received input from any process. */ | 4030 | Otherwise, return true iff we received input from any process. */ |
| 4020 | 4031 | ||
| 4021 | int | 4032 | int |
| 4022 | wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | 4033 | wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, |
| 4023 | int time_limit, microsecs; | 4034 | wait_for_cell, wait_proc, just_wait_proc) |
| 4024 | Lisp_Object read_kbd; | 4035 | int time_limit, microsecs, read_kbd, do_display; |
| 4025 | int do_display; | 4036 | Lisp_Object wait_for_cell; |
| 4037 | struct Lisp_Process *wait_proc; | ||
| 4038 | int just_wait_proc; | ||
| 4026 | { | 4039 | { |
| 4027 | register int channel, nfds; | 4040 | register int channel, nfds; |
| 4028 | SELECT_TYPE Available; | 4041 | SELECT_TYPE Available; |
| @@ -4032,33 +4045,19 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4032 | Lisp_Object proc; | 4045 | Lisp_Object proc; |
| 4033 | EMACS_TIME timeout, end_time; | 4046 | EMACS_TIME timeout, end_time; |
| 4034 | int wait_channel = -1; | 4047 | int wait_channel = -1; |
| 4035 | struct Lisp_Process *wait_proc = 0; | ||
| 4036 | int got_some_input = 0; | 4048 | int got_some_input = 0; |
| 4037 | /* Either nil or a cons cell, the car of which is of interest and | 4049 | /* Either nil or a cons cell, the car of which is of interest and |
| 4038 | may be changed outside of this routine. */ | 4050 | may be changed outside of this routine. */ |
| 4039 | Lisp_Object wait_for_cell = Qnil; | ||
| 4040 | int saved_waiting_for_user_input_p = waiting_for_user_input_p; | 4051 | int saved_waiting_for_user_input_p = waiting_for_user_input_p; |
| 4041 | 4052 | ||
| 4042 | FD_ZERO (&Available); | 4053 | FD_ZERO (&Available); |
| 4043 | FD_ZERO (&Connecting); | 4054 | FD_ZERO (&Connecting); |
| 4044 | 4055 | ||
| 4045 | /* If read_kbd is a process to watch, set wait_proc and wait_channel | 4056 | /* If wait_proc is a process to watch, set wait_channel accordingly. */ |
| 4046 | accordingly. */ | 4057 | if (wait_proc != NULL) |
| 4047 | if (PROCESSP (read_kbd)) | 4058 | wait_channel = XINT (wait_proc->infd); |
| 4048 | { | ||
| 4049 | wait_proc = XPROCESS (read_kbd); | ||
| 4050 | wait_channel = XINT (wait_proc->infd); | ||
| 4051 | XSETFASTINT (read_kbd, 0); | ||
| 4052 | } | ||
| 4053 | |||
| 4054 | /* If waiting for non-nil in a cell, record where. */ | ||
| 4055 | if (CONSP (read_kbd)) | ||
| 4056 | { | ||
| 4057 | wait_for_cell = read_kbd; | ||
| 4058 | XSETFASTINT (read_kbd, 0); | ||
| 4059 | } | ||
| 4060 | 4059 | ||
| 4061 | waiting_for_user_input_p = XINT (read_kbd); | 4060 | waiting_for_user_input_p = read_kbd; |
| 4062 | 4061 | ||
| 4063 | /* Since we may need to wait several times, | 4062 | /* Since we may need to wait several times, |
| 4064 | compute the absolute time to return at. */ | 4063 | compute the absolute time to return at. */ |
| @@ -4086,7 +4085,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4086 | /* If calling from keyboard input, do not quit | 4085 | /* If calling from keyboard input, do not quit |
| 4087 | since we want to return C-g as an input character. | 4086 | since we want to return C-g as an input character. |
| 4088 | Otherwise, do pending quit if requested. */ | 4087 | Otherwise, do pending quit if requested. */ |
| 4089 | if (XINT (read_kbd) >= 0) | 4088 | if (read_kbd >= 0) |
| 4090 | QUIT; | 4089 | QUIT; |
| 4091 | #ifdef SYNC_INPUT | 4090 | #ifdef SYNC_INPUT |
| 4092 | else if (interrupt_input_pending) | 4091 | else if (interrupt_input_pending) |
| @@ -4123,7 +4122,8 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4123 | But not if wait_for_cell; in those cases, | 4122 | But not if wait_for_cell; in those cases, |
| 4124 | the wait is supposed to be short, | 4123 | the wait is supposed to be short, |
| 4125 | and those callers cannot handle running arbitrary Lisp code here. */ | 4124 | and those callers cannot handle running arbitrary Lisp code here. */ |
| 4126 | if (NILP (wait_for_cell)) | 4125 | if (NILP (wait_for_cell) |
| 4126 | && just_wait_proc >= 0) | ||
| 4127 | { | 4127 | { |
| 4128 | EMACS_TIME timer_delay; | 4128 | EMACS_TIME timer_delay; |
| 4129 | 4129 | ||
| @@ -4151,7 +4151,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4151 | while (!detect_input_pending ()); | 4151 | while (!detect_input_pending ()); |
| 4152 | 4152 | ||
| 4153 | /* If there is unread keyboard input, also return. */ | 4153 | /* If there is unread keyboard input, also return. */ |
| 4154 | if (XINT (read_kbd) != 0 | 4154 | if (read_kbd != 0 |
| 4155 | && requeued_events_pending_p ()) | 4155 | && requeued_events_pending_p ()) |
| 4156 | break; | 4156 | break; |
| 4157 | 4157 | ||
| @@ -4169,7 +4169,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4169 | else if (time_limit != -1) | 4169 | else if (time_limit != -1) |
| 4170 | { | 4170 | { |
| 4171 | /* This is so a breakpoint can be put here. */ | 4171 | /* This is so a breakpoint can be put here. */ |
| 4172 | wait_reading_process_input_1 (); | 4172 | wait_reading_process_output_1 (); |
| 4173 | } | 4173 | } |
| 4174 | } | 4174 | } |
| 4175 | 4175 | ||
| @@ -4179,7 +4179,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4179 | It is important that we do this before checking for process | 4179 | It is important that we do this before checking for process |
| 4180 | activity. If we get a SIGCHLD after the explicit checks for | 4180 | activity. If we get a SIGCHLD after the explicit checks for |
| 4181 | process activity, timeout is the only way we will know. */ | 4181 | process activity, timeout is the only way we will know. */ |
| 4182 | if (XINT (read_kbd) < 0) | 4182 | if (read_kbd < 0) |
| 4183 | set_waiting_for_input (&timeout); | 4183 | set_waiting_for_input (&timeout); |
| 4184 | 4184 | ||
| 4185 | /* If status of something has changed, and no input is | 4185 | /* If status of something has changed, and no input is |
| @@ -4259,14 +4259,21 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4259 | 4259 | ||
| 4260 | /* Wait till there is something to do */ | 4260 | /* Wait till there is something to do */ |
| 4261 | 4261 | ||
| 4262 | if (!NILP (wait_for_cell)) | 4262 | 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)) | ||
| 4263 | { | 4270 | { |
| 4264 | Available = non_process_wait_mask; | 4271 | Available = non_process_wait_mask; |
| 4265 | check_connect = check_delay = 0; | 4272 | check_connect = check_delay = 0; |
| 4266 | } | 4273 | } |
| 4267 | else | 4274 | else |
| 4268 | { | 4275 | { |
| 4269 | if (! XINT (read_kbd)) | 4276 | if (! read_kbd) |
| 4270 | Available = non_keyboard_wait_mask; | 4277 | Available = non_keyboard_wait_mask; |
| 4271 | else | 4278 | else |
| 4272 | Available = input_wait_mask; | 4279 | Available = input_wait_mask; |
| @@ -4283,12 +4290,12 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4283 | { | 4290 | { |
| 4284 | clear_waiting_for_input (); | 4291 | clear_waiting_for_input (); |
| 4285 | redisplay_preserve_echo_area (11); | 4292 | redisplay_preserve_echo_area (11); |
| 4286 | if (XINT (read_kbd) < 0) | 4293 | if (read_kbd < 0) |
| 4287 | set_waiting_for_input (&timeout); | 4294 | set_waiting_for_input (&timeout); |
| 4288 | } | 4295 | } |
| 4289 | 4296 | ||
| 4290 | no_avail = 0; | 4297 | no_avail = 0; |
| 4291 | if (XINT (read_kbd) && detect_input_pending ()) | 4298 | if (read_kbd && detect_input_pending ()) |
| 4292 | { | 4299 | { |
| 4293 | nfds = 0; | 4300 | nfds = 0; |
| 4294 | no_avail = 1; | 4301 | no_avail = 1; |
| @@ -4405,10 +4412,10 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4405 | /* If we are using polling for input, | 4412 | /* If we are using polling for input, |
| 4406 | and we see input available, make it get read now. | 4413 | and we see input available, make it get read now. |
| 4407 | Otherwise it might not actually get read for a second. | 4414 | Otherwise it might not actually get read for a second. |
| 4408 | And on hpux, since we turn off polling in wait_reading_process_input, | 4415 | And on hpux, since we turn off polling in wait_reading_process_output, |
| 4409 | it might never get read at all if we don't spend much time | 4416 | it might never get read at all if we don't spend much time |
| 4410 | outside of wait_reading_process_input. */ | 4417 | outside of wait_reading_process_output. */ |
| 4411 | if (XINT (read_kbd) && interrupt_input | 4418 | if (read_kbd && interrupt_input |
| 4412 | && keyboard_bit_set (&Available) | 4419 | && keyboard_bit_set (&Available) |
| 4413 | && input_polling_used ()) | 4420 | && input_polling_used ()) |
| 4414 | kill (getpid (), SIGALRM); | 4421 | kill (getpid (), SIGALRM); |
| @@ -4418,7 +4425,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4418 | /* If there is any, return immediately | 4425 | /* If there is any, return immediately |
| 4419 | to give it higher priority than subprocesses */ | 4426 | to give it higher priority than subprocesses */ |
| 4420 | 4427 | ||
| 4421 | if (XINT (read_kbd) != 0) | 4428 | if (read_kbd != 0) |
| 4422 | { | 4429 | { |
| 4423 | int old_timers_run = timers_run; | 4430 | int old_timers_run = timers_run; |
| 4424 | struct buffer *old_buffer = current_buffer; | 4431 | struct buffer *old_buffer = current_buffer; |
| @@ -4443,7 +4450,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4443 | } | 4450 | } |
| 4444 | 4451 | ||
| 4445 | /* If there is unread keyboard input, also return. */ | 4452 | /* If there is unread keyboard input, also return. */ |
| 4446 | if (XINT (read_kbd) != 0 | 4453 | if (read_kbd != 0 |
| 4447 | && requeued_events_pending_p ()) | 4454 | && requeued_events_pending_p ()) |
| 4448 | break; | 4455 | break; |
| 4449 | 4456 | ||
| @@ -4454,7 +4461,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4454 | That would causes delays in pasting selections, for example. | 4461 | That would causes delays in pasting selections, for example. |
| 4455 | 4462 | ||
| 4456 | (We used to do this only if wait_for_cell.) */ | 4463 | (We used to do this only if wait_for_cell.) */ |
| 4457 | if (XINT (read_kbd) == 0 && detect_input_pending ()) | 4464 | if (read_kbd == 0 && detect_input_pending ()) |
| 4458 | { | 4465 | { |
| 4459 | swallow_events (do_display); | 4466 | swallow_events (do_display); |
| 4460 | #if 0 /* Exiting when read_kbd doesn't request that seems wrong, though. */ | 4467 | #if 0 /* Exiting when read_kbd doesn't request that seems wrong, though. */ |
| @@ -4473,7 +4480,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4473 | In that case, there really is no input and no SIGIO, | 4480 | In that case, there really is no input and no SIGIO, |
| 4474 | but select says there is input. */ | 4481 | but select says there is input. */ |
| 4475 | 4482 | ||
| 4476 | if (XINT (read_kbd) && interrupt_input | 4483 | if (read_kbd && interrupt_input |
| 4477 | && keyboard_bit_set (&Available) && ! noninteractive) | 4484 | && keyboard_bit_set (&Available) && ! noninteractive) |
| 4478 | kill (getpid (), SIGIO); | 4485 | kill (getpid (), SIGIO); |
| 4479 | #endif | 4486 | #endif |
| @@ -4483,7 +4490,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4483 | 4490 | ||
| 4484 | /* If checking input just got us a size-change event from X, | 4491 | /* If checking input just got us a size-change event from X, |
| 4485 | obey it now if we should. */ | 4492 | obey it now if we should. */ |
| 4486 | if (XINT (read_kbd) || ! NILP (wait_for_cell)) | 4493 | if (read_kbd || ! NILP (wait_for_cell)) |
| 4487 | do_pending_window_change (0); | 4494 | do_pending_window_change (0); |
| 4488 | 4495 | ||
| 4489 | /* Check for data from a process. */ | 4496 | /* Check for data from a process. */ |
| @@ -4658,7 +4665,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4658 | /* If calling from keyboard input, do not quit | 4665 | /* If calling from keyboard input, do not quit |
| 4659 | since we want to return C-g as an input character. | 4666 | since we want to return C-g as an input character. |
| 4660 | Otherwise, do pending quit if requested. */ | 4667 | Otherwise, do pending quit if requested. */ |
| 4661 | if (XINT (read_kbd) >= 0) | 4668 | if (read_kbd >= 0) |
| 4662 | { | 4669 | { |
| 4663 | /* Prevent input_pending from remaining set if we quit. */ | 4670 | /* Prevent input_pending from remaining set if we quit. */ |
| 4664 | clear_input_pending (); | 4671 | clear_input_pending (); |
| @@ -5303,7 +5310,6 @@ send_process (proc, buf, len, object) | |||
| 5303 | that may allow the program | 5310 | that may allow the program |
| 5304 | to finish doing output and read more. */ | 5311 | to finish doing output and read more. */ |
| 5305 | { | 5312 | { |
| 5306 | Lisp_Object zero; | ||
| 5307 | int offset = 0; | 5313 | int offset = 0; |
| 5308 | 5314 | ||
| 5309 | #ifdef BROKEN_PTY_READ_AFTER_EAGAIN | 5315 | #ifdef BROKEN_PTY_READ_AFTER_EAGAIN |
| @@ -5338,11 +5344,10 @@ send_process (proc, buf, len, object) | |||
| 5338 | else if (STRINGP (object)) | 5344 | else if (STRINGP (object)) |
| 5339 | offset = buf - SDATA (object); | 5345 | offset = buf - SDATA (object); |
| 5340 | 5346 | ||
| 5341 | XSETFASTINT (zero, 0); | ||
| 5342 | #ifdef EMACS_HAS_USECS | 5347 | #ifdef EMACS_HAS_USECS |
| 5343 | wait_reading_process_input (0, 20000, zero, 0); | 5348 | wait_reading_process_output (0, 20000, 0, 0, Qnil, NULL, 0); |
| 5344 | #else | 5349 | #else |
| 5345 | wait_reading_process_input (1, 0, zero, 0); | 5350 | wait_reading_process_output (1, 0, 0, 0, Qnil, NULL, 0); |
| 5346 | #endif | 5351 | #endif |
| 5347 | 5352 | ||
| 5348 | if (BUFFERP (object)) | 5353 | if (BUFFERP (object)) |
| @@ -5548,29 +5553,36 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 5548 | work. If the system has it, use it. */ | 5553 | work. If the system has it, use it. */ |
| 5549 | #ifdef HAVE_TERMIOS | 5554 | #ifdef HAVE_TERMIOS |
| 5550 | struct termios t; | 5555 | struct termios t; |
| 5556 | cc_t *sig_char = NULL; | ||
| 5557 | |||
| 5558 | tcgetattr (XINT (p->infd), &t); | ||
| 5551 | 5559 | ||
| 5552 | switch (signo) | 5560 | switch (signo) |
| 5553 | { | 5561 | { |
| 5554 | case SIGINT: | 5562 | case SIGINT: |
| 5555 | tcgetattr (XINT (p->infd), &t); | 5563 | sig_char = &t.c_cc[VINTR]; |
| 5556 | send_process (proc, &t.c_cc[VINTR], 1, Qnil); | 5564 | break; |
| 5557 | return; | ||
| 5558 | 5565 | ||
| 5559 | case SIGQUIT: | 5566 | case SIGQUIT: |
| 5560 | tcgetattr (XINT (p->infd), &t); | 5567 | sig_char = &t.c_cc[VQUIT]; |
| 5561 | send_process (proc, &t.c_cc[VQUIT], 1, Qnil); | 5568 | break; |
| 5562 | return; | ||
| 5563 | 5569 | ||
| 5564 | case SIGTSTP: | 5570 | case SIGTSTP: |
| 5565 | tcgetattr (XINT (p->infd), &t); | ||
| 5566 | #if defined (VSWTCH) && !defined (PREFER_VSUSP) | 5571 | #if defined (VSWTCH) && !defined (PREFER_VSUSP) |
| 5567 | send_process (proc, &t.c_cc[VSWTCH], 1, Qnil); | 5572 | sig_char = &t.c_cc[VSWTCH]; |
| 5568 | #else | 5573 | #else |
| 5569 | send_process (proc, &t.c_cc[VSUSP], 1, Qnil); | 5574 | sig_char = &t.c_cc[VSUSP]; |
| 5570 | #endif | 5575 | #endif |
| 5571 | return; | 5576 | break; |
| 5572 | } | 5577 | } |
| 5573 | 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. */ | ||
| 5574 | #else /* ! HAVE_TERMIOS */ | 5586 | #else /* ! HAVE_TERMIOS */ |
| 5575 | 5587 | ||
| 5576 | /* On Berkeley descendants, the following IOCTL's retrieve the | 5588 | /* On Berkeley descendants, the following IOCTL's retrieve the |
| @@ -5627,9 +5639,12 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 5627 | you'd better be using one of the alternatives above! */ | 5639 | you'd better be using one of the alternatives above! */ |
| 5628 | #endif /* ! defined (TCGETA) */ | 5640 | #endif /* ! defined (TCGETA) */ |
| 5629 | #endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */ | 5641 | #endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */ |
| 5630 | #endif /* ! defined HAVE_TERMIOS */ | 5642 | /* In this case, the code above should alway returns. */ |
| 5631 | abort (); | 5643 | abort (); |
| 5632 | /* The code above always returns from the function. */ | 5644 | #endif /* ! defined HAVE_TERMIOS */ |
| 5645 | |||
| 5646 | /* The code above may fall through if it can't | ||
| 5647 | handle the signal. */ | ||
| 5633 | #endif /* defined (SIGNALS_VIA_CHARACTERS) */ | 5648 | #endif /* defined (SIGNALS_VIA_CHARACTERS) */ |
| 5634 | 5649 | ||
| 5635 | #ifdef TIOCGPGRP | 5650 | #ifdef TIOCGPGRP |
| @@ -6201,7 +6216,7 @@ sigchld_handler (signo) | |||
| 6201 | FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); | 6216 | FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); |
| 6202 | } | 6217 | } |
| 6203 | 6218 | ||
| 6204 | /* Tell wait_reading_process_input that it needs to wake up and | 6219 | /* Tell wait_reading_process_output that it needs to wake up and |
| 6205 | look around. */ | 6220 | look around. */ |
| 6206 | if (input_available_clear_time) | 6221 | if (input_available_clear_time) |
| 6207 | EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); | 6222 | EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); |
| @@ -6219,7 +6234,7 @@ sigchld_handler (signo) | |||
| 6219 | else if (WIFSIGNALED (w)) | 6234 | else if (WIFSIGNALED (w)) |
| 6220 | synch_process_termsig = WTERMSIG (w); | 6235 | synch_process_termsig = WTERMSIG (w); |
| 6221 | 6236 | ||
| 6222 | /* Tell wait_reading_process_input that it needs to wake up and | 6237 | /* Tell wait_reading_process_output that it needs to wake up and |
| 6223 | look around. */ | 6238 | look around. */ |
| 6224 | if (input_available_clear_time) | 6239 | if (input_available_clear_time) |
| 6225 | EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); | 6240 | EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); |
| @@ -6861,10 +6876,9 @@ Lisp_Object QCtype; | |||
| 6861 | 1 to return when input is available, or | 6876 | 1 to return when input is available, or |
| 6862 | -1 means caller will actually read the input, so don't throw to | 6877 | -1 means caller will actually read the input, so don't throw to |
| 6863 | the quit handler. | 6878 | the quit handler. |
| 6864 | a cons cell, meaning wait until its car is non-nil | 6879 | |
| 6865 | (and gobble terminal input into the buffer if any arrives), or | 6880 | see full version for other parameters. We know that wait_proc will |
| 6866 | We know that read_kbd will never be a Lisp_Process, since | 6881 | always be NULL, since `subprocesses' isn't defined. |
| 6867 | `subprocesses' isn't defined. | ||
| 6868 | 6882 | ||
| 6869 | do_display != 0 means redisplay should be done to show subprocess | 6883 | do_display != 0 means redisplay should be done to show subprocess |
| 6870 | output that arrives. | 6884 | output that arrives. |
| @@ -6872,27 +6886,17 @@ Lisp_Object QCtype; | |||
| 6872 | Return true iff we received input from any process. */ | 6886 | Return true iff we received input from any process. */ |
| 6873 | 6887 | ||
| 6874 | int | 6888 | int |
| 6875 | wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | 6889 | wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, |
| 6876 | int time_limit, microsecs; | 6890 | wait_for_cell, wait_proc, just_wait_proc) |
| 6877 | Lisp_Object read_kbd; | 6891 | int time_limit, microsecs, read_kbd, do_display; |
| 6878 | int do_display; | 6892 | Lisp_Object wait_for_cell; |
| 6893 | struct Lisp_Process *wait_proc; | ||
| 6894 | int just_wait_proc; | ||
| 6879 | { | 6895 | { |
| 6880 | register int nfds; | 6896 | register int nfds; |
| 6881 | EMACS_TIME end_time, timeout; | 6897 | EMACS_TIME end_time, timeout; |
| 6882 | SELECT_TYPE waitchannels; | 6898 | SELECT_TYPE waitchannels; |
| 6883 | int xerrno; | 6899 | int xerrno; |
| 6884 | /* Either nil or a cons cell, the car of which is of interest and | ||
| 6885 | may be changed outside of this routine. */ | ||
| 6886 | Lisp_Object wait_for_cell; | ||
| 6887 | |||
| 6888 | wait_for_cell = Qnil; | ||
| 6889 | |||
| 6890 | /* If waiting for non-nil in a cell, record where. */ | ||
| 6891 | if (CONSP (read_kbd)) | ||
| 6892 | { | ||
| 6893 | wait_for_cell = read_kbd; | ||
| 6894 | XSETFASTINT (read_kbd, 0); | ||
| 6895 | } | ||
| 6896 | 6900 | ||
| 6897 | /* What does time_limit really mean? */ | 6901 | /* What does time_limit really mean? */ |
| 6898 | if (time_limit || microsecs) | 6902 | if (time_limit || microsecs) |
| @@ -6915,7 +6919,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 6915 | /* If calling from keyboard input, do not quit | 6919 | /* If calling from keyboard input, do not quit |
| 6916 | since we want to return C-g as an input character. | 6920 | since we want to return C-g as an input character. |
| 6917 | Otherwise, do pending quit if requested. */ | 6921 | Otherwise, do pending quit if requested. */ |
| 6918 | if (XINT (read_kbd) >= 0) | 6922 | if (read_kbd >= 0) |
| 6919 | QUIT; | 6923 | QUIT; |
| 6920 | 6924 | ||
| 6921 | /* Exit now if the cell we're waiting for became non-nil. */ | 6925 | /* Exit now if the cell we're waiting for became non-nil. */ |
| @@ -6966,7 +6970,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 6966 | while (!detect_input_pending ()); | 6970 | while (!detect_input_pending ()); |
| 6967 | 6971 | ||
| 6968 | /* If there is unread keyboard input, also return. */ | 6972 | /* If there is unread keyboard input, also return. */ |
| 6969 | if (XINT (read_kbd) != 0 | 6973 | if (read_kbd != 0 |
| 6970 | && requeued_events_pending_p ()) | 6974 | && requeued_events_pending_p ()) |
| 6971 | break; | 6975 | break; |
| 6972 | 6976 | ||
| @@ -6984,12 +6988,12 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 6984 | 6988 | ||
| 6985 | /* Cause C-g and alarm signals to take immediate action, | 6989 | /* Cause C-g and alarm signals to take immediate action, |
| 6986 | and cause input available signals to zero out timeout. */ | 6990 | and cause input available signals to zero out timeout. */ |
| 6987 | if (XINT (read_kbd) < 0) | 6991 | if (read_kbd < 0) |
| 6988 | set_waiting_for_input (&timeout); | 6992 | set_waiting_for_input (&timeout); |
| 6989 | 6993 | ||
| 6990 | /* Wait till there is something to do. */ | 6994 | /* Wait till there is something to do. */ |
| 6991 | 6995 | ||
| 6992 | if (! XINT (read_kbd) && NILP (wait_for_cell)) | 6996 | if (! read_kbd && NILP (wait_for_cell)) |
| 6993 | FD_ZERO (&waitchannels); | 6997 | FD_ZERO (&waitchannels); |
| 6994 | else | 6998 | else |
| 6995 | FD_SET (0, &waitchannels); | 6999 | FD_SET (0, &waitchannels); |
| @@ -7000,11 +7004,11 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 7000 | { | 7004 | { |
| 7001 | clear_waiting_for_input (); | 7005 | clear_waiting_for_input (); |
| 7002 | redisplay_preserve_echo_area (15); | 7006 | redisplay_preserve_echo_area (15); |
| 7003 | if (XINT (read_kbd) < 0) | 7007 | if (read_kbd < 0) |
| 7004 | set_waiting_for_input (&timeout); | 7008 | set_waiting_for_input (&timeout); |
| 7005 | } | 7009 | } |
| 7006 | 7010 | ||
| 7007 | if (XINT (read_kbd) && detect_input_pending ()) | 7011 | if (read_kbd && detect_input_pending ()) |
| 7008 | { | 7012 | { |
| 7009 | nfds = 0; | 7013 | nfds = 0; |
| 7010 | FD_ZERO (&waitchannels); | 7014 | FD_ZERO (&waitchannels); |
| @@ -7040,13 +7044,13 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 7040 | kill (getpid (), SIGIO); | 7044 | kill (getpid (), SIGIO); |
| 7041 | #endif | 7045 | #endif |
| 7042 | #ifdef SIGIO | 7046 | #ifdef SIGIO |
| 7043 | if (XINT (read_kbd) && interrupt_input && (waitchannels & 1)) | 7047 | if (read_kbd && interrupt_input && (waitchannels & 1)) |
| 7044 | kill (getpid (), SIGIO); | 7048 | kill (getpid (), SIGIO); |
| 7045 | #endif | 7049 | #endif |
| 7046 | 7050 | ||
| 7047 | /* Check for keyboard input */ | 7051 | /* Check for keyboard input */ |
| 7048 | 7052 | ||
| 7049 | if ((XINT (read_kbd) != 0) | 7053 | if (read_kbd |
| 7050 | && detect_input_pending_run_timers (do_display)) | 7054 | && detect_input_pending_run_timers (do_display)) |
| 7051 | { | 7055 | { |
| 7052 | swallow_events (do_display); | 7056 | swallow_events (do_display); |
| @@ -7055,7 +7059,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 7055 | } | 7059 | } |
| 7056 | 7060 | ||
| 7057 | /* If there is unread keyboard input, also return. */ | 7061 | /* If there is unread keyboard input, also return. */ |
| 7058 | if (XINT (read_kbd) != 0 | 7062 | if (read_kbd |
| 7059 | && requeued_events_pending_p ()) | 7063 | && requeued_events_pending_p ()) |
| 7060 | break; | 7064 | break; |
| 7061 | 7065 | ||