aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorKaroly Lorentey2004-08-23 10:12:04 +0000
committerKaroly Lorentey2004-08-23 10:12:04 +0000
commitf5272227fd50f5c3846e63f600601b625b6a6182 (patch)
tree85312708f4fa58f09eaeafe2403f9b99c883ebbc /src/process.c
parent90376e6f1799b1268d6df6d7934b593ee0c4f575 (diff)
parent49eac10f921716d0cac034c977731fddd115388a (diff)
downloademacs-f5272227fd50f5c3846e63f600601b625b6a6182.tar.gz
emacs-f5272227fd50f5c3846e63f600601b625b6a6182.zip
Merged in changes from CVS trunk.
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-501 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-502 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-503 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-504 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-505 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-236
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c201
1 files changed, 86 insertions, 115 deletions
diff --git a/src/process.c b/src/process.c
index 1cebdf07875..dab7bdc3198 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3777,13 +3777,12 @@ Return non-nil iff we received any output before the timeout expired. */)
3777 else 3777 else
3778 seconds = NILP (process) ? -1 : 0; 3778 seconds = NILP (process) ? -1 : 0;
3779 3779
3780 if (NILP (process))
3781 XSETFASTINT (process, 0);
3782
3783 return 3780 return
3784 (wait_reading_process_input (seconds, useconds, process, 3781 (wait_reading_process_output (seconds, useconds, 0, 0,
3785 NILP (just_this_one) ? 0 : 3782 Qnil,
3786 !INTEGERP (just_this_one) ? -1 : -2) 3783 !NILP (process) ? XPROCESS (process) : NULL,
3784 NILP (just_this_one) ? 0 :
3785 !INTEGERP (just_this_one) ? 1 : -1)
3787 ? Qt : Qnil); 3786 ? Qt : Qnil);
3788} 3787}
3789 3788
@@ -3983,12 +3982,12 @@ server_accept_connection (server, channel)
3983 lisp code is being evalled. 3982 lisp code is being evalled.
3984 This is also used in record_asynch_buffer_change. 3983 This is also used in record_asynch_buffer_change.
3985 For that purpose, this must be 0 3984 For that purpose, this must be 0
3986 when not inside wait_reading_process_input. */ 3985 when not inside wait_reading_process_output. */
3987static int waiting_for_user_input_p; 3986static int waiting_for_user_input_p;
3988 3987
3989/* This is here so breakpoints can be put on it. */ 3988/* This is here so breakpoints can be put on it. */
3990static void 3989static void
3991wait_reading_process_input_1 () 3990wait_reading_process_output_1 ()
3992{ 3991{
3993} 3992}
3994 3993
@@ -4010,28 +4009,32 @@ wait_reading_process_input_1 ()
4010 1 to return when input is available, or 4009 1 to return when input is available, or
4011 -1 meaning caller will actually read the input, so don't throw to 4010 -1 meaning caller will actually read the input, so don't throw to
4012 the quit handler, or 4011 the quit handler, or
4013 a cons cell, meaning wait until its car is non-nil 4012
4014 (and gobble terminal input into the buffer if any arrives), or 4013 DO_DISPLAY != 0 means redisplay should be done to show subprocess
4015 a process object, meaning wait until something arrives from that
4016 process. The return value is true iff we read some input from
4017 that process.
4018
4019 If READ_KBD is a process object, DO_DISPLAY < 0 means handle only
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 output that arrives.
4024 4015
4025 If READ_KBD is a pointer to a struct Lisp_Process, then the 4016 If WAIT_FOR_CELL is a cons cell, wait until its car is non-nil
4026 function returns true iff we received input from that process 4017 (and gobble terminal input into the buffer if any arrives).
4027 before the timeout elapsed. 4018
4019 If WAIT_PROC is specified, wait until something arrives from that
4020 process. The return value is true iff we read some input from
4021 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.
4028 Otherwise, return true iff we received input from any process. */ 4029 Otherwise, return true iff we received input from any process. */
4029 4030
4030int 4031int
4031wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) 4032wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4032 int time_limit, microsecs; 4033 wait_for_cell, wait_proc, just_wait_proc)
4033 Lisp_Object read_kbd; 4034 int time_limit, microsecs, read_kbd, do_display;
4034 int do_display; 4035 Lisp_Object wait_for_cell;
4036 struct Lisp_Process *wait_proc;
4037 int just_wait_proc;
4035{ 4038{
4036 register int channel, nfds; 4039 register int channel, nfds;
4037 SELECT_TYPE Available; 4040 SELECT_TYPE Available;
@@ -4041,39 +4044,19 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4041 Lisp_Object proc; 4044 Lisp_Object proc;
4042 EMACS_TIME timeout, end_time; 4045 EMACS_TIME timeout, end_time;
4043 int wait_channel = -1; 4046 int wait_channel = -1;
4044 struct Lisp_Process *wait_proc = 0;
4045 int just_wait_proc = 0;
4046 int got_some_input = 0; 4047 int got_some_input = 0;
4047 /* Either nil or a cons cell, the car of which is of interest and 4048 /* Either nil or a cons cell, the car of which is of interest and
4048 may be changed outside of this routine. */ 4049 may be changed outside of this routine. */
4049 Lisp_Object wait_for_cell = Qnil;
4050 int saved_waiting_for_user_input_p = waiting_for_user_input_p; 4050 int saved_waiting_for_user_input_p = waiting_for_user_input_p;
4051 4051
4052 FD_ZERO (&Available); 4052 FD_ZERO (&Available);
4053 FD_ZERO (&Connecting); 4053 FD_ZERO (&Connecting);
4054 4054
4055 /* If read_kbd is a process to watch, set wait_proc and wait_channel 4055 /* If wait_proc is a process to watch, set wait_channel accordingly. */
4056 accordingly. */ 4056 if (wait_proc != NULL)
4057 if (PROCESSP (read_kbd)) 4057 wait_channel = XINT (wait_proc->infd);
4058 {
4059 wait_proc = XPROCESS (read_kbd);
4060 wait_channel = XINT (wait_proc->infd);
4061 XSETFASTINT (read_kbd, 0);
4062 if (do_display < 0)
4063 {
4064 just_wait_proc = do_display;
4065 do_display = 0;
4066 }
4067 }
4068
4069 /* If waiting for non-nil in a cell, record where. */
4070 if (CONSP (read_kbd))
4071 {
4072 wait_for_cell = read_kbd;
4073 XSETFASTINT (read_kbd, 0);
4074 }
4075 4058
4076 waiting_for_user_input_p = XINT (read_kbd); 4059 waiting_for_user_input_p = read_kbd;
4077 4060
4078 /* Since we may need to wait several times, 4061 /* Since we may need to wait several times,
4079 compute the absolute time to return at. */ 4062 compute the absolute time to return at. */
@@ -4101,7 +4084,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4101 /* If calling from keyboard input, do not quit 4084 /* If calling from keyboard input, do not quit
4102 since we want to return C-g as an input character. 4085 since we want to return C-g as an input character.
4103 Otherwise, do pending quit if requested. */ 4086 Otherwise, do pending quit if requested. */
4104 if (XINT (read_kbd) >= 0) 4087 if (read_kbd >= 0)
4105 QUIT; 4088 QUIT;
4106#ifdef SYNC_INPUT 4089#ifdef SYNC_INPUT
4107 else if (interrupt_input_pending) 4090 else if (interrupt_input_pending)
@@ -4139,7 +4122,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4139 the wait is supposed to be short, 4122 the wait is supposed to be short,
4140 and those callers cannot handle running arbitrary Lisp code here. */ 4123 and those callers cannot handle running arbitrary Lisp code here. */
4141 if (NILP (wait_for_cell) 4124 if (NILP (wait_for_cell)
4142 && just_wait_proc != -2) 4125 && just_wait_proc >= 0)
4143 { 4126 {
4144 EMACS_TIME timer_delay; 4127 EMACS_TIME timer_delay;
4145 4128
@@ -4167,7 +4150,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4167 while (!detect_input_pending ()); 4150 while (!detect_input_pending ());
4168 4151
4169 /* If there is unread keyboard input, also return. */ 4152 /* If there is unread keyboard input, also return. */
4170 if (XINT (read_kbd) != 0 4153 if (read_kbd != 0
4171 && requeued_events_pending_p ()) 4154 && requeued_events_pending_p ())
4172 break; 4155 break;
4173 4156
@@ -4185,7 +4168,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4185 else if (time_limit != -1) 4168 else if (time_limit != -1)
4186 { 4169 {
4187 /* This is so a breakpoint can be put here. */ 4170 /* This is so a breakpoint can be put here. */
4188 wait_reading_process_input_1 (); 4171 wait_reading_process_output_1 ();
4189 } 4172 }
4190 } 4173 }
4191 4174
@@ -4195,7 +4178,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4195 It is important that we do this before checking for process 4178 It is important that we do this before checking for process
4196 activity. If we get a SIGCHLD after the explicit checks for 4179 activity. If we get a SIGCHLD after the explicit checks for
4197 process activity, timeout is the only way we will know. */ 4180 process activity, timeout is the only way we will know. */
4198 if (XINT (read_kbd) < 0) 4181 if (read_kbd < 0)
4199 set_waiting_for_input (&timeout); 4182 set_waiting_for_input (&timeout);
4200 4183
4201 /* If status of something has changed, and no input is 4184 /* If status of something has changed, and no input is
@@ -4275,8 +4258,10 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4275 4258
4276 /* Wait till there is something to do */ 4259 /* Wait till there is something to do */
4277 4260
4278 if (just_wait_proc) 4261 if (wait_proc && just_wait_proc)
4279 { 4262 {
4263 if (XINT (wait_proc->infd) < 0) /* Terminated */
4264 break;
4280 FD_SET (XINT (wait_proc->infd), &Available); 4265 FD_SET (XINT (wait_proc->infd), &Available);
4281 check_connect = check_delay = 0; 4266 check_connect = check_delay = 0;
4282 } 4267 }
@@ -4287,7 +4272,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4287 } 4272 }
4288 else 4273 else
4289 { 4274 {
4290 if (! XINT (read_kbd)) 4275 if (! read_kbd)
4291 Available = non_keyboard_wait_mask; 4276 Available = non_keyboard_wait_mask;
4292 else 4277 else
4293 Available = input_wait_mask; 4278 Available = input_wait_mask;
@@ -4304,12 +4289,12 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4304 { 4289 {
4305 clear_waiting_for_input (); 4290 clear_waiting_for_input ();
4306 redisplay_preserve_echo_area (11); 4291 redisplay_preserve_echo_area (11);
4307 if (XINT (read_kbd) < 0) 4292 if (read_kbd < 0)
4308 set_waiting_for_input (&timeout); 4293 set_waiting_for_input (&timeout);
4309 } 4294 }
4310 4295
4311 no_avail = 0; 4296 no_avail = 0;
4312 if (XINT (read_kbd) && detect_input_pending ()) 4297 if (read_kbd && detect_input_pending ())
4313 { 4298 {
4314 nfds = 0; 4299 nfds = 0;
4315 no_avail = 1; 4300 no_avail = 1;
@@ -4426,10 +4411,10 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4426 /* If we are using polling for input, 4411 /* If we are using polling for input,
4427 and we see input available, make it get read now. 4412 and we see input available, make it get read now.
4428 Otherwise it might not actually get read for a second. 4413 Otherwise it might not actually get read for a second.
4429 And on hpux, since we turn off polling in wait_reading_process_input, 4414 And on hpux, since we turn off polling in wait_reading_process_output,
4430 it might never get read at all if we don't spend much time 4415 it might never get read at all if we don't spend much time
4431 outside of wait_reading_process_input. */ 4416 outside of wait_reading_process_output. */
4432 if (XINT (read_kbd) && interrupt_input 4417 if (read_kbd && interrupt_input
4433 && keyboard_bit_set (&Available) 4418 && keyboard_bit_set (&Available)
4434 && input_polling_used ()) 4419 && input_polling_used ())
4435 kill (getpid (), SIGALRM); 4420 kill (getpid (), SIGALRM);
@@ -4439,7 +4424,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4439 /* If there is any, return immediately 4424 /* If there is any, return immediately
4440 to give it higher priority than subprocesses */ 4425 to give it higher priority than subprocesses */
4441 4426
4442 if (XINT (read_kbd) != 0) 4427 if (read_kbd != 0)
4443 { 4428 {
4444 int old_timers_run = timers_run; 4429 int old_timers_run = timers_run;
4445 struct buffer *old_buffer = current_buffer; 4430 struct buffer *old_buffer = current_buffer;
@@ -4464,7 +4449,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4464 } 4449 }
4465 4450
4466 /* If there is unread keyboard input, also return. */ 4451 /* If there is unread keyboard input, also return. */
4467 if (XINT (read_kbd) != 0 4452 if (read_kbd != 0
4468 && requeued_events_pending_p ()) 4453 && requeued_events_pending_p ())
4469 break; 4454 break;
4470 4455
@@ -4475,7 +4460,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4475 That would causes delays in pasting selections, for example. 4460 That would causes delays in pasting selections, for example.
4476 4461
4477 (We used to do this only if wait_for_cell.) */ 4462 (We used to do this only if wait_for_cell.) */
4478 if (XINT (read_kbd) == 0 && detect_input_pending ()) 4463 if (read_kbd == 0 && detect_input_pending ())
4479 { 4464 {
4480 swallow_events (do_display); 4465 swallow_events (do_display);
4481#if 0 /* Exiting when read_kbd doesn't request that seems wrong, though. */ 4466#if 0 /* Exiting when read_kbd doesn't request that seems wrong, though. */
@@ -4494,7 +4479,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4494 In that case, there really is no input and no SIGIO, 4479 In that case, there really is no input and no SIGIO,
4495 but select says there is input. */ 4480 but select says there is input. */
4496 4481
4497 if (XINT (read_kbd) && interrupt_input 4482 if (read_kbd && interrupt_input
4498 && keyboard_bit_set (&Available) && ! noninteractive) 4483 && keyboard_bit_set (&Available) && ! noninteractive)
4499 kill (getpid (), SIGIO); 4484 kill (getpid (), SIGIO);
4500#endif 4485#endif
@@ -4504,7 +4489,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4504 4489
4505 /* If checking input just got us a size-change event from X, 4490 /* If checking input just got us a size-change event from X,
4506 obey it now if we should. */ 4491 obey it now if we should. */
4507 if (XINT (read_kbd) || ! NILP (wait_for_cell)) 4492 if (read_kbd || ! NILP (wait_for_cell))
4508 do_pending_window_change (0); 4493 do_pending_window_change (0);
4509 4494
4510 /* Check for data from a process. */ 4495 /* Check for data from a process. */
@@ -4679,7 +4664,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4679 /* If calling from keyboard input, do not quit 4664 /* If calling from keyboard input, do not quit
4680 since we want to return C-g as an input character. 4665 since we want to return C-g as an input character.
4681 Otherwise, do pending quit if requested. */ 4666 Otherwise, do pending quit if requested. */
4682 if (XINT (read_kbd) >= 0) 4667 if (read_kbd >= 0)
4683 { 4668 {
4684 /* Prevent input_pending from remaining set if we quit. */ 4669 /* Prevent input_pending from remaining set if we quit. */
4685 clear_input_pending (); 4670 clear_input_pending ();
@@ -5326,7 +5311,6 @@ send_process (proc, buf, len, object)
5326 that may allow the program 5311 that may allow the program
5327 to finish doing output and read more. */ 5312 to finish doing output and read more. */
5328 { 5313 {
5329 Lisp_Object zero;
5330 int offset = 0; 5314 int offset = 0;
5331 5315
5332#ifdef BROKEN_PTY_READ_AFTER_EAGAIN 5316#ifdef BROKEN_PTY_READ_AFTER_EAGAIN
@@ -5361,11 +5345,10 @@ send_process (proc, buf, len, object)
5361 else if (STRINGP (object)) 5345 else if (STRINGP (object))
5362 offset = buf - SDATA (object); 5346 offset = buf - SDATA (object);
5363 5347
5364 XSETFASTINT (zero, 0);
5365#ifdef EMACS_HAS_USECS 5348#ifdef EMACS_HAS_USECS
5366 wait_reading_process_input (0, 20000, zero, 0); 5349 wait_reading_process_output (0, 20000, 0, 0, Qnil, NULL, 0);
5367#else 5350#else
5368 wait_reading_process_input (1, 0, zero, 0); 5351 wait_reading_process_output (1, 0, 0, 0, Qnil, NULL, 0);
5369#endif 5352#endif
5370 5353
5371 if (BUFFERP (object)) 5354 if (BUFFERP (object))
@@ -5594,17 +5577,13 @@ process_send_signal (process, signo, current_group, nomsg)
5594 break; 5577 break;
5595 } 5578 }
5596 5579
5597#ifndef _POSIX_VDISABLE 5580 if (sig_char && *sig_char != CDISABLE)
5598#ifdef CVDISABLE 5581 {
5599#define _POSIX_VDISABLE CVDISABLE 5582 send_process (proc, sig_char, 1, Qnil);
5600#else 5583 return;
5601#define _POSIX_VDISABLE '\0' 5584 }
5602#endif 5585 /* If we can't send the signal with a character,
5603#endif 5586 fall through and send it another way. */
5604
5605 if (sig_char && *sig_char != _POSIX_VDISABLE)
5606 send_process (proc, sig_char, 1, Qnil);
5607 return;
5608#else /* ! HAVE_TERMIOS */ 5587#else /* ! HAVE_TERMIOS */
5609 5588
5610 /* On Berkeley descendants, the following IOCTL's retrieve the 5589 /* On Berkeley descendants, the following IOCTL's retrieve the
@@ -5661,9 +5640,12 @@ process_send_signal (process, signo, current_group, nomsg)
5661 you'd better be using one of the alternatives above! */ 5640 you'd better be using one of the alternatives above! */
5662#endif /* ! defined (TCGETA) */ 5641#endif /* ! defined (TCGETA) */
5663#endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */ 5642#endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */
5664#endif /* ! defined HAVE_TERMIOS */ 5643 /* In this case, the code above should alway returns. */
5665 abort (); 5644 abort ();
5666 /* The code above always returns from the function. */ 5645#endif /* ! defined HAVE_TERMIOS */
5646
5647 /* The code above may fall through if it can't
5648 handle the signal. */
5667#endif /* defined (SIGNALS_VIA_CHARACTERS) */ 5649#endif /* defined (SIGNALS_VIA_CHARACTERS) */
5668 5650
5669#ifdef TIOCGPGRP 5651#ifdef TIOCGPGRP
@@ -6235,7 +6217,7 @@ sigchld_handler (signo)
6235 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); 6217 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask);
6236 } 6218 }
6237 6219
6238 /* Tell wait_reading_process_input that it needs to wake up and 6220 /* Tell wait_reading_process_output that it needs to wake up and
6239 look around. */ 6221 look around. */
6240 if (input_available_clear_time) 6222 if (input_available_clear_time)
6241 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); 6223 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
@@ -6253,7 +6235,7 @@ sigchld_handler (signo)
6253 else if (WIFSIGNALED (w)) 6235 else if (WIFSIGNALED (w))
6254 synch_process_termsig = WTERMSIG (w); 6236 synch_process_termsig = WTERMSIG (w);
6255 6237
6256 /* Tell wait_reading_process_input that it needs to wake up and 6238 /* Tell wait_reading_process_output that it needs to wake up and
6257 look around. */ 6239 look around. */
6258 if (input_available_clear_time) 6240 if (input_available_clear_time)
6259 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); 6241 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
@@ -6892,10 +6874,9 @@ Lisp_Object QCtype;
6892 1 to return when input is available, or 6874 1 to return when input is available, or
6893 -1 means caller will actually read the input, so don't throw to 6875 -1 means caller will actually read the input, so don't throw to
6894 the quit handler. 6876 the quit handler.
6895 a cons cell, meaning wait until its car is non-nil 6877
6896 (and gobble terminal input into the buffer if any arrives), or 6878 see full version for other parameters. We know that wait_proc will
6897 We know that read_kbd will never be a Lisp_Process, since 6879 always be NULL, since `subprocesses' isn't defined.
6898 `subprocesses' isn't defined.
6899 6880
6900 do_display != 0 means redisplay should be done to show subprocess 6881 do_display != 0 means redisplay should be done to show subprocess
6901 output that arrives. 6882 output that arrives.
@@ -6903,27 +6884,17 @@ Lisp_Object QCtype;
6903 Return true iff we received input from any process. */ 6884 Return true iff we received input from any process. */
6904 6885
6905int 6886int
6906wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) 6887wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
6907 int time_limit, microsecs; 6888 wait_for_cell, wait_proc, just_wait_proc)
6908 Lisp_Object read_kbd; 6889 int time_limit, microsecs, read_kbd, do_display;
6909 int do_display; 6890 Lisp_Object wait_for_cell;
6891 struct Lisp_Process *wait_proc;
6892 int just_wait_proc;
6910{ 6893{
6911 register int nfds; 6894 register int nfds;
6912 EMACS_TIME end_time, timeout; 6895 EMACS_TIME end_time, timeout;
6913 SELECT_TYPE waitchannels; 6896 SELECT_TYPE waitchannels;
6914 int xerrno; 6897 int xerrno;
6915 /* Either nil or a cons cell, the car of which is of interest and
6916 may be changed outside of this routine. */
6917 Lisp_Object wait_for_cell;
6918
6919 wait_for_cell = Qnil;
6920
6921 /* If waiting for non-nil in a cell, record where. */
6922 if (CONSP (read_kbd))
6923 {
6924 wait_for_cell = read_kbd;
6925 XSETFASTINT (read_kbd, 0);
6926 }
6927 6898
6928 /* What does time_limit really mean? */ 6899 /* What does time_limit really mean? */
6929 if (time_limit || microsecs) 6900 if (time_limit || microsecs)
@@ -6946,7 +6917,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
6946 /* If calling from keyboard input, do not quit 6917 /* If calling from keyboard input, do not quit
6947 since we want to return C-g as an input character. 6918 since we want to return C-g as an input character.
6948 Otherwise, do pending quit if requested. */ 6919 Otherwise, do pending quit if requested. */
6949 if (XINT (read_kbd) >= 0) 6920 if (read_kbd >= 0)
6950 QUIT; 6921 QUIT;
6951 6922
6952 /* Exit now if the cell we're waiting for became non-nil. */ 6923 /* Exit now if the cell we're waiting for became non-nil. */
@@ -6997,7 +6968,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
6997 while (!detect_input_pending ()); 6968 while (!detect_input_pending ());
6998 6969
6999 /* If there is unread keyboard input, also return. */ 6970 /* If there is unread keyboard input, also return. */
7000 if (XINT (read_kbd) != 0 6971 if (read_kbd != 0
7001 && requeued_events_pending_p ()) 6972 && requeued_events_pending_p ())
7002 break; 6973 break;
7003 6974
@@ -7015,12 +6986,12 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
7015 6986
7016 /* Cause C-g and alarm signals to take immediate action, 6987 /* Cause C-g and alarm signals to take immediate action,
7017 and cause input available signals to zero out timeout. */ 6988 and cause input available signals to zero out timeout. */
7018 if (XINT (read_kbd) < 0) 6989 if (read_kbd < 0)
7019 set_waiting_for_input (&timeout); 6990 set_waiting_for_input (&timeout);
7020 6991
7021 /* Wait till there is something to do. */ 6992 /* Wait till there is something to do. */
7022 6993
7023 if (! XINT (read_kbd) && NILP (wait_for_cell)) 6994 if (! read_kbd && NILP (wait_for_cell))
7024 FD_ZERO (&waitchannels); 6995 FD_ZERO (&waitchannels);
7025 else 6996 else
7026 FD_SET (0, &waitchannels); 6997 FD_SET (0, &waitchannels);
@@ -7031,11 +7002,11 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
7031 { 7002 {
7032 clear_waiting_for_input (); 7003 clear_waiting_for_input ();
7033 redisplay_preserve_echo_area (15); 7004 redisplay_preserve_echo_area (15);
7034 if (XINT (read_kbd) < 0) 7005 if (read_kbd < 0)
7035 set_waiting_for_input (&timeout); 7006 set_waiting_for_input (&timeout);
7036 } 7007 }
7037 7008
7038 if (XINT (read_kbd) && detect_input_pending ()) 7009 if (read_kbd && detect_input_pending ())
7039 { 7010 {
7040 nfds = 0; 7011 nfds = 0;
7041 FD_ZERO (&waitchannels); 7012 FD_ZERO (&waitchannels);
@@ -7071,13 +7042,13 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
7071 kill (getpid (), SIGIO); 7042 kill (getpid (), SIGIO);
7072#endif 7043#endif
7073#ifdef SIGIO 7044#ifdef SIGIO
7074 if (XINT (read_kbd) && interrupt_input && (waitchannels & 1)) 7045 if (read_kbd && interrupt_input && (waitchannels & 1))
7075 kill (getpid (), SIGIO); 7046 kill (getpid (), SIGIO);
7076#endif 7047#endif
7077 7048
7078 /* Check for keyboard input */ 7049 /* Check for keyboard input */
7079 7050
7080 if ((XINT (read_kbd) != 0) 7051 if (read_kbd
7081 && detect_input_pending_run_timers (do_display)) 7052 && detect_input_pending_run_timers (do_display))
7082 { 7053 {
7083 swallow_events (do_display); 7054 swallow_events (do_display);
@@ -7086,7 +7057,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
7086 } 7057 }
7087 7058
7088 /* If there is unread keyboard input, also return. */ 7059 /* If there is unread keyboard input, also return. */
7089 if (XINT (read_kbd) != 0 7060 if (read_kbd
7090 && requeued_events_pending_p ()) 7061 && requeued_events_pending_p ())
7091 break; 7062 break;
7092 7063