comparison src/process.c @ 56716:c126b8b6a314

* process.c (wait_reading_process_input): Clean up. Add wait_for_cell, wait_proc, and just_wait_proc args to avoid overloading `read_kbd' and `do_display' args. Change read_kbd arg to int. All callers changed.
author Kim F. Storm <storm@cua.dk>
date Thu, 19 Aug 2004 13:57:17 +0000
parents 7e315ff338bf
children 1686b397ef16
comparison
equal deleted inserted replaced
56715:3f2803fc673a 56716:c126b8b6a314
3775 seconds = -1; 3775 seconds = -1;
3776 } 3776 }
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_input (seconds, useconds, 0, 0,
3782 Qnil,
3783 !NILP (process) ? XPROCESS (process) : NULL,
3785 NILP (just_this_one) ? 0 : 3784 NILP (just_this_one) ? 0 :
3786 !INTEGERP (just_this_one) ? -1 : -2) 3785 !INTEGERP (just_this_one) ? 1 : -1)
3787 ? Qt : Qnil); 3786 ? Qt : Qnil);
3788 } 3787 }
3789 3788
3790 /* Accept a connection for server process SERVER on CHANNEL. */ 3789 /* Accept a connection for server process SERVER on CHANNEL. */
3791 3790
4008 READ_KBD is a lisp value: 4007 READ_KBD is a lisp value:
4009 0 to ignore keyboard input, or 4008 0 to ignore keyboard input, or
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
4030 int 4031 int
4031 wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) 4032 wait_reading_process_input (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;
4038 SELECT_TYPE Connecting; 4041 SELECT_TYPE Connecting;
4039 int check_connect, check_delay, no_avail; 4042 int check_connect, check_delay, no_avail;
4040 int xerrno; 4043 int xerrno;
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 { 4058
4059 wait_proc = XPROCESS (read_kbd); 4059 waiting_for_user_input_p = 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
4076 waiting_for_user_input_p = XINT (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. */
4080 if (time_limit || microsecs) 4063 if (time_limit || microsecs)
4081 { 4064 {
4099 int timeout_reduced_for_timers = 0; 4082 int timeout_reduced_for_timers = 0;
4100 4083
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)
4108 handle_async_input (); 4091 handle_async_input ();
4109 #endif 4092 #endif
4137 /* Normally we run timers here. 4120 /* Normally we run timers here.
4138 But not if wait_for_cell; in those cases, 4121 But not if wait_for_cell; in those cases,
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
4146 do 4129 do
4147 { 4130 {
4165 break; 4148 break;
4166 } 4149 }
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
4174 if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1) 4157 if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1)
4175 { 4158 {
4193 and cause input available signals to zero out timeout. 4176 and cause input available signals to zero out timeout.
4194 4177
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
4202 available, notify the user of the change right away. After 4185 available, notify the user of the change right away. After
4203 this explicit check, we'll let the SIGCHLD handler zap 4186 this explicit check, we'll let the SIGCHLD handler zap
4273 break; 4256 break;
4274 } 4257 }
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 }
4283 else if (!NILP (wait_for_cell)) 4268 else if (!NILP (wait_for_cell))
4284 { 4269 {
4285 Available = non_process_wait_mask; 4270 Available = non_process_wait_mask;
4286 check_connect = check_delay = 0; 4271 check_connect = check_delay = 0;
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;
4294 check_connect = (num_pending_connects > 0); 4279 check_connect = (num_pending_connects > 0);
4295 check_delay = wait_channel >= 0 ? 0 : process_output_delay_count; 4280 check_delay = wait_channel >= 0 ? 0 : process_output_delay_count;
4302 displaying a trashed screen. */ 4287 displaying a trashed screen. */
4303 if (frame_garbaged && do_display) 4288 if (frame_garbaged && 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;
4316 } 4301 }
4317 else 4302 else
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_input,
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_input. */
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);
4436 #endif 4421 #endif
4437 4422
4438 /* Check for keyboard input */ 4423 /* Check for keyboard input */
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;
4446 int leave = 0; 4431 int leave = 0;
4447 4432
4462 if (leave) 4447 if (leave)
4463 break; 4448 break;
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
4471 /* If we are not checking for keyboard input now, 4456 /* If we are not checking for keyboard input now,
4472 do process events (but don't run any timers). 4457 do process events (but don't run any timers).
4473 This is so that X events will be processed. 4458 This is so that X events will be processed.
4474 Otherwise they may have to wait until polling takes place. 4459 Otherwise they may have to wait until polling takes place.
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. */
4482 if (detect_input_pending ()) 4467 if (detect_input_pending ())
4483 break; 4468 break;
4492 /* If we think we have keyboard input waiting, but didn't get SIGIO, 4477 /* If we think we have keyboard input waiting, but didn't get SIGIO,
4493 go read it. This can happen with X on BSD after logging out. 4478 go read it. This can happen with X on BSD after logging out.
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
4501 4486
4502 if (! wait_proc) 4487 if (! wait_proc)
4503 got_some_input |= nfds > 0; 4488 got_some_input |= nfds > 0;
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. */
4511 if (no_avail || nfds == 0) 4496 if (no_avail || nfds == 0)
4512 continue; 4497 continue;
4677 waiting_for_user_input_p = saved_waiting_for_user_input_p; 4662 waiting_for_user_input_p = saved_waiting_for_user_input_p;
4678 4663
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 ();
4686 QUIT; 4671 QUIT;
4687 } 4672 }
5324 ) 5309 )
5325 /* Buffer is full. Wait, accepting input; 5310 /* Buffer is full. Wait, accepting input;
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
5333 /* A gross hack to work around a bug in FreeBSD. 5317 /* A gross hack to work around a bug in FreeBSD.
5334 In the following sequence, read(2) returns 5318 In the following sequence, read(2) returns
5359 if (BUFFERP (object)) 5343 if (BUFFERP (object))
5360 offset = BUF_PTR_BYTE_POS (XBUFFER (object), buf); 5344 offset = BUF_PTR_BYTE_POS (XBUFFER (object), buf);
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_input (0, 20000, 0, 0, Qnil, NULL, 0);
5367 #else 5350 #else
5368 wait_reading_process_input (1, 0, zero, 0); 5351 wait_reading_process_input (1, 0, 0, 0, Qnil, NULL, 0);
5369 #endif 5352 #endif
5370 5353
5371 if (BUFFERP (object)) 5354 if (BUFFERP (object))
5372 buf = BUF_BYTE_ADDRESS (XBUFFER (object), offset); 5355 buf = BUF_BYTE_ADDRESS (XBUFFER (object), offset);
5373 else if (STRINGP (object)) 5356 else if (STRINGP (object))
6885 read_kbd is a Lisp_Object: 6868 read_kbd is a Lisp_Object:
6886 0 to ignore keyboard input, or 6869 0 to ignore keyboard input, or
6887 1 to return when input is available, or 6870 1 to return when input is available, or
6888 -1 means caller will actually read the input, so don't throw to 6871 -1 means caller will actually read the input, so don't throw to
6889 the quit handler. 6872 the quit handler.
6890 a cons cell, meaning wait until its car is non-nil 6873
6891 (and gobble terminal input into the buffer if any arrives), or 6874 see full version for other parameters. We know that wait_proc will
6892 We know that read_kbd will never be a Lisp_Process, since 6875 always be NULL, since `subprocesses' isn't defined.
6893 `subprocesses' isn't defined.
6894 6876
6895 do_display != 0 means redisplay should be done to show subprocess 6877 do_display != 0 means redisplay should be done to show subprocess
6896 output that arrives. 6878 output that arrives.
6897 6879
6898 Return true iff we received input from any process. */ 6880 Return true iff we received input from any process. */
6899 6881
6900 int 6882 int
6901 wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) 6883 wait_reading_process_input (time_limit, microsecs, read_kbd, do_display,
6902 int time_limit, microsecs; 6884 wait_for_cell, wait_proc, just_wait_proc)
6903 Lisp_Object read_kbd; 6885 int time_limit, microsecs, read_kbd, do_display;
6904 int do_display; 6886 Lisp_Object wait_for_cell;
6887 struct Lisp_Process *wait_proc;
6888 int just_wait_proc;
6905 { 6889 {
6906 register int nfds; 6890 register int nfds;
6907 EMACS_TIME end_time, timeout; 6891 EMACS_TIME end_time, timeout;
6908 SELECT_TYPE waitchannels; 6892 SELECT_TYPE waitchannels;
6909 int xerrno; 6893 int xerrno;
6910 /* Either nil or a cons cell, the car of which is of interest and
6911 may be changed outside of this routine. */
6912 Lisp_Object wait_for_cell;
6913
6914 wait_for_cell = Qnil;
6915
6916 /* If waiting for non-nil in a cell, record where. */
6917 if (CONSP (read_kbd))
6918 {
6919 wait_for_cell = read_kbd;
6920 XSETFASTINT (read_kbd, 0);
6921 }
6922 6894
6923 /* What does time_limit really mean? */ 6895 /* What does time_limit really mean? */
6924 if (time_limit || microsecs) 6896 if (time_limit || microsecs)
6925 { 6897 {
6926 EMACS_GET_TIME (end_time); 6898 EMACS_GET_TIME (end_time);
6939 int timeout_reduced_for_timers = 0; 6911 int timeout_reduced_for_timers = 0;
6940 6912
6941 /* If calling from keyboard input, do not quit 6913 /* If calling from keyboard input, do not quit
6942 since we want to return C-g as an input character. 6914 since we want to return C-g as an input character.
6943 Otherwise, do pending quit if requested. */ 6915 Otherwise, do pending quit if requested. */
6944 if (XINT (read_kbd) >= 0) 6916 if (read_kbd >= 0)
6945 QUIT; 6917 QUIT;
6946 6918
6947 /* Exit now if the cell we're waiting for became non-nil. */ 6919 /* Exit now if the cell we're waiting for became non-nil. */
6948 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) 6920 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
6949 break; 6921 break;
6990 break; 6962 break;
6991 } 6963 }
6992 while (!detect_input_pending ()); 6964 while (!detect_input_pending ());
6993 6965
6994 /* If there is unread keyboard input, also return. */ 6966 /* If there is unread keyboard input, also return. */
6995 if (XINT (read_kbd) != 0 6967 if (read_kbd != 0
6996 && requeued_events_pending_p ()) 6968 && requeued_events_pending_p ())
6997 break; 6969 break;
6998 6970
6999 if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1) 6971 if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1)
7000 { 6972 {
7008 } 6980 }
7009 } 6981 }
7010 6982
7011 /* Cause C-g and alarm signals to take immediate action, 6983 /* Cause C-g and alarm signals to take immediate action,
7012 and cause input available signals to zero out timeout. */ 6984 and cause input available signals to zero out timeout. */
7013 if (XINT (read_kbd) < 0) 6985 if (read_kbd < 0)
7014 set_waiting_for_input (&timeout); 6986 set_waiting_for_input (&timeout);
7015 6987
7016 /* Wait till there is something to do. */ 6988 /* Wait till there is something to do. */
7017 6989
7018 if (! XINT (read_kbd) && NILP (wait_for_cell)) 6990 if (! read_kbd && NILP (wait_for_cell))
7019 FD_ZERO (&waitchannels); 6991 FD_ZERO (&waitchannels);
7020 else 6992 else
7021 FD_SET (0, &waitchannels); 6993 FD_SET (0, &waitchannels);
7022 6994
7023 /* If a frame has been newly mapped and needs updating, 6995 /* If a frame has been newly mapped and needs updating,
7024 reprocess its display stuff. */ 6996 reprocess its display stuff. */
7025 if (frame_garbaged && do_display) 6997 if (frame_garbaged && do_display)
7026 { 6998 {
7027 clear_waiting_for_input (); 6999 clear_waiting_for_input ();
7028 redisplay_preserve_echo_area (15); 7000 redisplay_preserve_echo_area (15);
7029 if (XINT (read_kbd) < 0) 7001 if (read_kbd < 0)
7030 set_waiting_for_input (&timeout); 7002 set_waiting_for_input (&timeout);
7031 } 7003 }
7032 7004
7033 if (XINT (read_kbd) && detect_input_pending ()) 7005 if (read_kbd && detect_input_pending ())
7034 { 7006 {
7035 nfds = 0; 7007 nfds = 0;
7036 FD_ZERO (&waitchannels); 7008 FD_ZERO (&waitchannels);
7037 } 7009 }
7038 else 7010 else
7064 else if (nfds > 0 && (waitchannels & 1) && interrupt_input) 7036 else if (nfds > 0 && (waitchannels & 1) && interrupt_input)
7065 /* System sometimes fails to deliver SIGIO. */ 7037 /* System sometimes fails to deliver SIGIO. */
7066 kill (getpid (), SIGIO); 7038 kill (getpid (), SIGIO);
7067 #endif 7039 #endif
7068 #ifdef SIGIO 7040 #ifdef SIGIO
7069 if (XINT (read_kbd) && interrupt_input && (waitchannels & 1)) 7041 if (read_kbd && interrupt_input && (waitchannels & 1))
7070 kill (getpid (), SIGIO); 7042 kill (getpid (), SIGIO);
7071 #endif 7043 #endif
7072 7044
7073 /* Check for keyboard input */ 7045 /* Check for keyboard input */
7074 7046
7075 if ((XINT (read_kbd) != 0) 7047 if (read_kbd
7076 && detect_input_pending_run_timers (do_display)) 7048 && detect_input_pending_run_timers (do_display))
7077 { 7049 {
7078 swallow_events (do_display); 7050 swallow_events (do_display);
7079 if (detect_input_pending_run_timers (do_display)) 7051 if (detect_input_pending_run_timers (do_display))
7080 break; 7052 break;
7081 } 7053 }
7082 7054
7083 /* If there is unread keyboard input, also return. */ 7055 /* If there is unread keyboard input, also return. */
7084 if (XINT (read_kbd) != 0 7056 if (read_kbd
7085 && requeued_events_pending_p ()) 7057 && requeued_events_pending_p ())
7086 break; 7058 break;
7087 7059
7088 /* If wait_for_cell. check for keyboard input 7060 /* If wait_for_cell. check for keyboard input
7089 but don't run any timers. 7061 but don't run any timers.