diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 69 |
1 files changed, 51 insertions, 18 deletions
diff --git a/src/process.c b/src/process.c index ff3f79158ca..1cebdf07875 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -3718,7 +3718,7 @@ close_process_descs () | |||
| 3718 | } | 3718 | } |
| 3719 | 3719 | ||
| 3720 | DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, | 3720 | DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, |
| 3721 | 0, 3, 0, | 3721 | 0, 4, 0, |
| 3722 | doc: /* Allow any pending output from subprocesses to be read by Emacs. | 3722 | 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. | 3723 | 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 | 3724 | Non-nil arg PROCESS means do not return until some output has been received |
| @@ -3726,15 +3726,20 @@ from PROCESS. | |||
| 3726 | Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of | 3726 | 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 | 3727 | seconds and microseconds to wait; return after that much time whether |
| 3728 | or not there is input. | 3728 | 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. | ||
| 3729 | Return non-nil iff we received any output before the timeout expired. */) | 3732 | Return non-nil iff we received any output before the timeout expired. */) |
| 3730 | (process, timeout, timeout_msecs) | 3733 | (process, timeout, timeout_msecs, just_this_one) |
| 3731 | register Lisp_Object process, timeout, timeout_msecs; | 3734 | register Lisp_Object process, timeout, timeout_msecs, just_this_one; |
| 3732 | { | 3735 | { |
| 3733 | int seconds; | 3736 | int seconds; |
| 3734 | int useconds; | 3737 | int useconds; |
| 3735 | 3738 | ||
| 3736 | if (! NILP (process)) | 3739 | if (! NILP (process)) |
| 3737 | CHECK_PROCESS (process); | 3740 | CHECK_PROCESS (process); |
| 3741 | else | ||
| 3742 | just_this_one = Qnil; | ||
| 3738 | 3743 | ||
| 3739 | if (! NILP (timeout_msecs)) | 3744 | if (! NILP (timeout_msecs)) |
| 3740 | { | 3745 | { |
| @@ -3776,7 +3781,9 @@ Return non-nil iff we received any output before the timeout expired. */) | |||
| 3776 | XSETFASTINT (process, 0); | 3781 | XSETFASTINT (process, 0); |
| 3777 | 3782 | ||
| 3778 | return | 3783 | return |
| 3779 | (wait_reading_process_input (seconds, useconds, process, 0) | 3784 | (wait_reading_process_input (seconds, useconds, process, |
| 3785 | NILP (just_this_one) ? 0 : | ||
| 3786 | !INTEGERP (just_this_one) ? -1 : -2) | ||
| 3780 | ? Qt : Qnil); | 3787 | ? Qt : Qnil); |
| 3781 | } | 3788 | } |
| 3782 | 3789 | ||
| @@ -4009,8 +4016,11 @@ wait_reading_process_input_1 () | |||
| 4009 | process. The return value is true iff we read some input from | 4016 | process. The return value is true iff we read some input from |
| 4010 | that process. | 4017 | that process. |
| 4011 | 4018 | ||
| 4012 | DO_DISPLAY != 0 means redisplay should be done to show subprocess | 4019 | If READ_KBD is a process object, DO_DISPLAY < 0 means handle only |
| 4013 | output that arrives. | 4020 | output from that process (suspending output from other processes) |
| 4021 | and DO_DISPLAY == -2 specifically means don't run any timers either. | ||
| 4022 | Otherwise, != 0 means redisplay should be done to show subprocess | ||
| 4023 | output that arrives. | ||
| 4014 | 4024 | ||
| 4015 | If READ_KBD is a pointer to a struct Lisp_Process, then the | 4025 | If READ_KBD is a pointer to a struct Lisp_Process, then the |
| 4016 | function returns true iff we received input from that process | 4026 | function returns true iff we received input from that process |
| @@ -4032,6 +4042,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4032 | EMACS_TIME timeout, end_time; | 4042 | EMACS_TIME timeout, end_time; |
| 4033 | int wait_channel = -1; | 4043 | int wait_channel = -1; |
| 4034 | struct Lisp_Process *wait_proc = 0; | 4044 | struct Lisp_Process *wait_proc = 0; |
| 4045 | int just_wait_proc = 0; | ||
| 4035 | int got_some_input = 0; | 4046 | int got_some_input = 0; |
| 4036 | /* Either nil or a cons cell, the car of which is of interest and | 4047 | /* Either nil or a cons cell, the car of which is of interest and |
| 4037 | may be changed outside of this routine. */ | 4048 | may be changed outside of this routine. */ |
| @@ -4048,6 +4059,11 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4048 | wait_proc = XPROCESS (read_kbd); | 4059 | wait_proc = XPROCESS (read_kbd); |
| 4049 | wait_channel = XINT (wait_proc->infd); | 4060 | wait_channel = XINT (wait_proc->infd); |
| 4050 | XSETFASTINT (read_kbd, 0); | 4061 | XSETFASTINT (read_kbd, 0); |
| 4062 | if (do_display < 0) | ||
| 4063 | { | ||
| 4064 | just_wait_proc = do_display; | ||
| 4065 | do_display = 0; | ||
| 4066 | } | ||
| 4051 | } | 4067 | } |
| 4052 | 4068 | ||
| 4053 | /* If waiting for non-nil in a cell, record where. */ | 4069 | /* If waiting for non-nil in a cell, record where. */ |
| @@ -4122,7 +4138,8 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4122 | But not if wait_for_cell; in those cases, | 4138 | But not if wait_for_cell; in those cases, |
| 4123 | the wait is supposed to be short, | 4139 | the wait is supposed to be short, |
| 4124 | and those callers cannot handle running arbitrary Lisp code here. */ | 4140 | and those callers cannot handle running arbitrary Lisp code here. */ |
| 4125 | if (NILP (wait_for_cell)) | 4141 | if (NILP (wait_for_cell) |
| 4142 | && just_wait_proc != -2) | ||
| 4126 | { | 4143 | { |
| 4127 | EMACS_TIME timer_delay; | 4144 | EMACS_TIME timer_delay; |
| 4128 | 4145 | ||
| @@ -4258,7 +4275,12 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 4258 | 4275 | ||
| 4259 | /* Wait till there is something to do */ | 4276 | /* Wait till there is something to do */ |
| 4260 | 4277 | ||
| 4261 | if (!NILP (wait_for_cell)) | 4278 | if (just_wait_proc) |
| 4279 | { | ||
| 4280 | FD_SET (XINT (wait_proc->infd), &Available); | ||
| 4281 | check_connect = check_delay = 0; | ||
| 4282 | } | ||
| 4283 | else if (!NILP (wait_for_cell)) | ||
| 4262 | { | 4284 | { |
| 4263 | Available = non_process_wait_mask; | 4285 | Available = non_process_wait_mask; |
| 4264 | check_connect = check_delay = 0; | 4286 | check_connect = check_delay = 0; |
| @@ -5549,29 +5571,40 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 5549 | work. If the system has it, use it. */ | 5571 | work. If the system has it, use it. */ |
| 5550 | #ifdef HAVE_TERMIOS | 5572 | #ifdef HAVE_TERMIOS |
| 5551 | struct termios t; | 5573 | struct termios t; |
| 5574 | cc_t *sig_char = NULL; | ||
| 5575 | |||
| 5576 | tcgetattr (XINT (p->infd), &t); | ||
| 5552 | 5577 | ||
| 5553 | switch (signo) | 5578 | switch (signo) |
| 5554 | { | 5579 | { |
| 5555 | case SIGINT: | 5580 | case SIGINT: |
| 5556 | tcgetattr (XINT (p->infd), &t); | 5581 | sig_char = &t.c_cc[VINTR]; |
| 5557 | send_process (proc, &t.c_cc[VINTR], 1, Qnil); | 5582 | break; |
| 5558 | return; | ||
| 5559 | 5583 | ||
| 5560 | case SIGQUIT: | 5584 | case SIGQUIT: |
| 5561 | tcgetattr (XINT (p->infd), &t); | 5585 | sig_char = &t.c_cc[VQUIT]; |
| 5562 | send_process (proc, &t.c_cc[VQUIT], 1, Qnil); | 5586 | break; |
| 5563 | return; | ||
| 5564 | 5587 | ||
| 5565 | case SIGTSTP: | 5588 | case SIGTSTP: |
| 5566 | tcgetattr (XINT (p->infd), &t); | ||
| 5567 | #if defined (VSWTCH) && !defined (PREFER_VSUSP) | 5589 | #if defined (VSWTCH) && !defined (PREFER_VSUSP) |
| 5568 | send_process (proc, &t.c_cc[VSWTCH], 1, Qnil); | 5590 | sig_char = &t.c_cc[VSWTCH]; |
| 5569 | #else | 5591 | #else |
| 5570 | send_process (proc, &t.c_cc[VSUSP], 1, Qnil); | 5592 | sig_char = &t.c_cc[VSUSP]; |
| 5571 | #endif | 5593 | #endif |
| 5572 | return; | 5594 | break; |
| 5573 | } | 5595 | } |
| 5574 | 5596 | ||
| 5597 | #ifndef _POSIX_VDISABLE | ||
| 5598 | #ifdef CVDISABLE | ||
| 5599 | #define _POSIX_VDISABLE CVDISABLE | ||
| 5600 | #else | ||
| 5601 | #define _POSIX_VDISABLE '\0' | ||
| 5602 | #endif | ||
| 5603 | #endif | ||
| 5604 | |||
| 5605 | if (sig_char && *sig_char != _POSIX_VDISABLE) | ||
| 5606 | send_process (proc, sig_char, 1, Qnil); | ||
| 5607 | return; | ||
| 5575 | #else /* ! HAVE_TERMIOS */ | 5608 | #else /* ! HAVE_TERMIOS */ |
| 5576 | 5609 | ||
| 5577 | /* On Berkeley descendants, the following IOCTL's retrieve the | 5610 | /* On Berkeley descendants, the following IOCTL's retrieve the |