comparison src/process.c @ 14802:45827a5afe4d

[!subprocesses] (wait_reading_process_input): Port the timer changes from the other wait_reading_process_input.
author Richard M. Stallman <rms@gnu.org>
date Sun, 10 Mar 1996 14:38:37 +0000
parents e4a9806c1e83
children 232b90ad50e8
comparison
equal deleted inserted replaced
14801:8bf3083f6499 14802:45827a5afe4d
3851 stop_polling (); 3851 stop_polling ();
3852 3852
3853 for (;;) 3853 for (;;)
3854 { 3854 {
3855 int nfds; 3855 int nfds;
3856 int timeout_reduced_for_timers = 0;
3856 3857
3857 if (XINT (read_kbd)) 3858 if (XINT (read_kbd))
3858 FD_SET (0, &waitchannels); 3859 FD_SET (0, &waitchannels);
3859 else 3860 else
3860 FD_ZERO (&waitchannels); 3861 FD_ZERO (&waitchannels);
3863 since we want to return C-g as an input character. 3864 since we want to return C-g as an input character.
3864 Otherwise, do pending quit if requested. */ 3865 Otherwise, do pending quit if requested. */
3865 if (XINT (read_kbd) >= 0) 3866 if (XINT (read_kbd) >= 0)
3866 QUIT; 3867 QUIT;
3867 3868
3869 /* Compute time from now till when time limit is up */
3870 /* Exit if already run out */
3868 if (timeout_p) 3871 if (timeout_p)
3869 { 3872 {
3870 EMACS_GET_TIME (*timeout_p); 3873 EMACS_GET_TIME (*timeout_p);
3871 EMACS_SUB_TIME (*timeout_p, end_time, *timeout_p); 3874 EMACS_SUB_TIME (*timeout_p, end_time, *timeout_p);
3872 if (EMACS_TIME_NEG_P (*timeout_p)) 3875 if (EMACS_TIME_NEG_P (*timeout_p))
3873 break; 3876 break;
3874 } 3877 }
3875 3878
3879 /* If our caller will not immediately handle keyboard events,
3880 run timer events directly.
3881 (Callers that will immediately read keyboard events
3882 call timer_delay on their own.) */
3883 if (read_kbd >= 0)
3884 {
3885 EMACS_TIME timer_delay;
3886 int old_timers_run = timers_run;
3887 timer_delay = timer_check (1);
3888 if (timers_run != old_timers_run && do_display)
3889 redisplay_preserve_echo_area ();
3890 if (! EMACS_TIME_NEG_P (timer_delay) && timeout_p)
3891 {
3892 EMACS_TIME difference;
3893 EMACS_SUB_TIME (difference, timer_delay, *timeout_p);
3894 if (EMACS_TIME_NEG_P (difference))
3895 {
3896 *timeout_p = timer_delay;
3897 timeout_reduced_for_timers = 1;
3898 }
3899 }
3900 }
3901
3876 /* Cause C-g and alarm signals to take immediate action, 3902 /* Cause C-g and alarm signals to take immediate action,
3877 and cause input available signals to zero out timeout. */ 3903 and cause input available signals to zero out timeout. */
3878 if (XINT (read_kbd) < 0) 3904 if (XINT (read_kbd) < 0)
3879 set_waiting_for_input (&timeout); 3905 set_waiting_for_input (&timeout);
3880 3906
3881 /* If a frame has been newly mapped and needs updating, 3907 /* If a frame has been newly mapped and needs updating,
3882 reprocess its display stuff. */ 3908 reprocess its display stuff. */
3883 if (frame_garbaged && do_display) 3909 if (frame_garbaged && do_display)
3884 redisplay_preserve_echo_area (); 3910 redisplay_preserve_echo_area ();
3885 3911
3886 if (XINT (read_kbd) && detect_input_pending ()) 3912 nfds = 1;
3887 nfds = 0; 3913 if (XINT (read_kbd) < 0 && detect_input_pending ())
3888 else 3914 {
3915 swallow_events (do_display);
3916 if (detect_input_pending ())
3917 nfds = 0;
3918 }
3919
3920 if ((XINT (read_kbd) > 0)
3921 && detect_input_pending_run_timers (do_display))
3922 {
3923 swallow_events (do_display);
3924 if (detect_input_pending_run_timers (do_display))
3925 nfds = 0;
3926 }
3927
3928 if (nfds)
3889 nfds = select (1, &waitchannels, (SELECT_TYPE *)0, (SELECT_TYPE *)0, 3929 nfds = select (1, &waitchannels, (SELECT_TYPE *)0, (SELECT_TYPE *)0,
3890 timeout_p); 3930 timeout_p);
3891 3931
3892 /* Make C-g and alarm signals set flags again */ 3932 /* Make C-g and alarm signals set flags again */
3893 clear_waiting_for_input (); 3933 clear_waiting_for_input ();
3912 kill (getpid (), SIGIO); 3952 kill (getpid (), SIGIO);
3913 #endif 3953 #endif
3914 3954
3915 /* If we have timed out (nfds == 0) or found some input (nfds > 0), 3955 /* If we have timed out (nfds == 0) or found some input (nfds > 0),
3916 we should exit. */ 3956 we should exit. */
3917 if (nfds >= 0) 3957 if (nfds >= 0 && ! timeout_reduced_for_timers)
3918 break; 3958 break;
3919 } 3959 }
3920 3960
3921 start_polling (); 3961 start_polling ();
3922 3962