diff options
| author | Richard M. Stallman | 1996-04-14 17:45:31 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-04-14 17:45:31 +0000 |
| commit | 0a65b0328259bcb5e3589cd6ffe75f1484c819af (patch) | |
| tree | 1a2effaa2bf945d4aa69bea3d37e815320ca4201 /src/process.c | |
| parent | 8cdaacaf133d68cf0ce7d20cc84888028dd1b3b6 (diff) | |
| download | emacs-0a65b0328259bcb5e3589cd6ffe75f1484c819af.tar.gz emacs-0a65b0328259bcb5e3589cd6ffe75f1484c819af.zip | |
(wait_reading_process_input) [!subprocesses]: Handle
the case of READ_KBD being a cons cell. Retry the timer check
after a timer fired. (All of these make this definition
consistent with the one that supports async subprocesses.)
(wait_reading_process_input, both definitions):
Use plain detect_input_pending just before the select call.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 82 |
1 files changed, 57 insertions, 25 deletions
diff --git a/src/process.c b/src/process.c index 09d262f0c6f..6db62dc6f35 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -2174,19 +2174,14 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 2174 | set_waiting_for_input (&timeout); | 2174 | set_waiting_for_input (&timeout); |
| 2175 | } | 2175 | } |
| 2176 | 2176 | ||
| 2177 | { | 2177 | if (XINT (read_kbd) && detect_input_pending ()) |
| 2178 | int old_timers_run = timers_run; | 2178 | { |
| 2179 | if (XINT (read_kbd) && detect_input_pending_run_timers (do_display)) | 2179 | nfds = 0; |
| 2180 | { | 2180 | FD_ZERO (&Available); |
| 2181 | nfds = 0; | 2181 | } |
| 2182 | FD_ZERO (&Available); | 2182 | else |
| 2183 | } | 2183 | nfds = select (MAXDESC, &Available, (SELECT_TYPE *)0, (SELECT_TYPE *)0, |
| 2184 | else if (timers_run != old_timers_run) | 2184 | &timeout); |
| 2185 | ; | ||
| 2186 | else | ||
| 2187 | nfds = select (MAXDESC, &Available, (SELECT_TYPE *)0, (SELECT_TYPE *)0, | ||
| 2188 | &timeout); | ||
| 2189 | } | ||
| 2190 | 2185 | ||
| 2191 | xerrno = errno; | 2186 | xerrno = errno; |
| 2192 | 2187 | ||
| @@ -3830,6 +3825,8 @@ extern int timers_run; | |||
| 3830 | 1 to return when input is available, or | 3825 | 1 to return when input is available, or |
| 3831 | -1 means caller will actually read the input, so don't throw to | 3826 | -1 means caller will actually read the input, so don't throw to |
| 3832 | the quit handler. | 3827 | the quit handler. |
| 3828 | a cons cell, meaning wait until its car is non-nil | ||
| 3829 | (and gobble terminal input into the buffer if any arrives), or | ||
| 3833 | We know that read_kbd will never be a Lisp_Process, since | 3830 | We know that read_kbd will never be a Lisp_Process, since |
| 3834 | `subprocesses' isn't defined. | 3831 | `subprocesses' isn't defined. |
| 3835 | 3832 | ||
| @@ -3847,6 +3844,14 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 3847 | EMACS_TIME end_time, timeout; | 3844 | EMACS_TIME end_time, timeout; |
| 3848 | SELECT_TYPE waitchannels; | 3845 | SELECT_TYPE waitchannels; |
| 3849 | int xerrno; | 3846 | int xerrno; |
| 3847 | Lisp_Object *wait_for_cell = 0; | ||
| 3848 | |||
| 3849 | /* If waiting for non-nil in a cell, record where. */ | ||
| 3850 | if (CONSP (read_kbd)) | ||
| 3851 | { | ||
| 3852 | wait_for_cell = &XCONS (read_kbd)->car; | ||
| 3853 | XSETFASTINT (read_kbd, 0); | ||
| 3854 | } | ||
| 3850 | 3855 | ||
| 3851 | /* What does time_limit really mean? */ | 3856 | /* What does time_limit really mean? */ |
| 3852 | if (time_limit || microsecs) | 3857 | if (time_limit || microsecs) |
| @@ -3874,17 +3879,16 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 3874 | int nfds; | 3879 | int nfds; |
| 3875 | int timeout_reduced_for_timers = 0; | 3880 | int timeout_reduced_for_timers = 0; |
| 3876 | 3881 | ||
| 3877 | if (XINT (read_kbd)) | ||
| 3878 | FD_SET (0, &waitchannels); | ||
| 3879 | else | ||
| 3880 | FD_ZERO (&waitchannels); | ||
| 3881 | |||
| 3882 | /* If calling from keyboard input, do not quit | 3882 | /* If calling from keyboard input, do not quit |
| 3883 | since we want to return C-g as an input character. | 3883 | since we want to return C-g as an input character. |
| 3884 | Otherwise, do pending quit if requested. */ | 3884 | Otherwise, do pending quit if requested. */ |
| 3885 | if (XINT (read_kbd) >= 0) | 3885 | if (XINT (read_kbd) >= 0) |
| 3886 | QUIT; | 3886 | QUIT; |
| 3887 | 3887 | ||
| 3888 | /* Exit now if the cell we're waiting for became non-nil. */ | ||
| 3889 | if (wait_for_cell && ! NILP (*wait_for_cell)) | ||
| 3890 | break; | ||
| 3891 | |||
| 3888 | /* Compute time from now till when time limit is up */ | 3892 | /* Compute time from now till when time limit is up */ |
| 3889 | /* Exit if already run out */ | 3893 | /* Exit if already run out */ |
| 3890 | if (time_limit > 0 || microsecs) | 3894 | if (time_limit > 0 || microsecs) |
| @@ -3899,13 +3903,22 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 3899 | run timer events directly. | 3903 | run timer events directly. |
| 3900 | (Callers that will immediately read keyboard events | 3904 | (Callers that will immediately read keyboard events |
| 3901 | call timer_delay on their own.) */ | 3905 | call timer_delay on their own.) */ |
| 3902 | if (XINT (read_kbd) >= 0) | 3906 | if (1) |
| 3903 | { | 3907 | { |
| 3904 | EMACS_TIME timer_delay; | 3908 | EMACS_TIME timer_delay; |
| 3905 | int old_timers_run = timers_run; | 3909 | int old_timers_run; |
| 3910 | |||
| 3911 | retry: | ||
| 3912 | old_timers_run = timers_run; | ||
| 3906 | timer_delay = timer_check (1); | 3913 | timer_delay = timer_check (1); |
| 3907 | if (timers_run != old_timers_run && do_display) | 3914 | if (timers_run != old_timers_run && do_display) |
| 3908 | redisplay_preserve_echo_area (); | 3915 | { |
| 3916 | redisplay_preserve_echo_area (); | ||
| 3917 | /* We must retry, since a timer may have requeued itself | ||
| 3918 | and that could alter the time delay. */ | ||
| 3919 | goto retry; | ||
| 3920 | } | ||
| 3921 | |||
| 3909 | if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1) | 3922 | if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1) |
| 3910 | { | 3923 | { |
| 3911 | EMACS_TIME difference; | 3924 | EMACS_TIME difference; |
| @@ -3923,15 +3936,30 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 3923 | if (XINT (read_kbd) < 0) | 3936 | if (XINT (read_kbd) < 0) |
| 3924 | set_waiting_for_input (&timeout); | 3937 | set_waiting_for_input (&timeout); |
| 3925 | 3938 | ||
| 3939 | /* Wait till there is something to do. */ | ||
| 3940 | |||
| 3941 | if (! XINT (read_kbd) && wait_for_cell == 0) | ||
| 3942 | FD_ZERO (&waitchannels); | ||
| 3943 | else | ||
| 3944 | FD_SET (0, &waitchannels); | ||
| 3945 | |||
| 3926 | /* If a frame has been newly mapped and needs updating, | 3946 | /* If a frame has been newly mapped and needs updating, |
| 3927 | reprocess its display stuff. */ | 3947 | reprocess its display stuff. */ |
| 3928 | if (frame_garbaged && do_display) | 3948 | if (frame_garbaged && do_display) |
| 3929 | redisplay_preserve_echo_area (); | 3949 | { |
| 3950 | clear_waiting_for_input (); | ||
| 3951 | redisplay_preserve_echo_area (); | ||
| 3952 | if (XINT (read_kbd) < 0) | ||
| 3953 | set_waiting_for_input (&timeout); | ||
| 3954 | } | ||
| 3930 | 3955 | ||
| 3931 | { | 3956 | { |
| 3932 | int old_timers_run = timers_run; | 3957 | int old_timers_run = timers_run; |
| 3933 | if (XINT (read_kbd) && detect_input_pending_run_timers (do_display)) | 3958 | if (XINT (read_kbd) && detect_input_pending ()) |
| 3934 | nfds = 0; | 3959 | { |
| 3960 | nfds = 0; | ||
| 3961 | FD_ZERO (&waitchannels); | ||
| 3962 | } | ||
| 3935 | else if (timers_run != old_timers_run) | 3963 | else if (timers_run != old_timers_run) |
| 3936 | ; | 3964 | ; |
| 3937 | else | 3965 | else |
| @@ -3972,13 +4000,17 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |||
| 3972 | 4000 | ||
| 3973 | /* Check for keyboard input */ | 4001 | /* Check for keyboard input */ |
| 3974 | 4002 | ||
| 3975 | if (XINT (read_kbd) != 0 | 4003 | if ((XINT (read_kbd) != 0 || wait_for_cell) |
| 3976 | && detect_input_pending_run_timers (do_display)) | 4004 | && detect_input_pending_run_timers (do_display)) |
| 3977 | { | 4005 | { |
| 3978 | swallow_events (do_display); | 4006 | swallow_events (do_display); |
| 3979 | if (detect_input_pending_run_timers (do_display)) | 4007 | if (detect_input_pending_run_timers (do_display)) |
| 3980 | break; | 4008 | break; |
| 3981 | } | 4009 | } |
| 4010 | |||
| 4011 | /* Exit now if the cell we're waiting for became non-nil. */ | ||
| 4012 | if (wait_for_cell && ! NILP (*wait_for_cell)) | ||
| 4013 | break; | ||
| 3982 | } | 4014 | } |
| 3983 | 4015 | ||
| 3984 | start_polling (); | 4016 | start_polling (); |