aboutsummaryrefslogtreecommitdiffstats
path: root/src/mac.c
diff options
context:
space:
mode:
authorSteven Tamm2002-12-08 05:58:34 +0000
committerSteven Tamm2002-12-08 05:58:34 +0000
commit2b187eacbec96224ef0029335dc6f36ef7964f29 (patch)
tree62d95d5f5917758e26204705b907fc40ef505d82 /src/mac.c
parent6ef0a87ef76e6da709abe4395ba3d6bcab0c93ae (diff)
downloademacs-2b187eacbec96224ef0029335dc6f36ef7964f29.tar.gz
emacs-2b187eacbec96224ef0029335dc6f36ef7964f29.zip
sys_select: Call mac_check_for_quit_char every second while blocking
sys_read: Use sys_select to test for input first before calling read to allow sys_select to test for quit_char.
Diffstat (limited to 'src/mac.c')
-rw-r--r--src/mac.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/src/mac.c b/src/mac.c
index 833ee5f3bdc..439f900db5b 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -2751,6 +2751,7 @@ and t is the same as `SECONDARY'. */)
2751#undef select 2751#undef select
2752 2752
2753extern int inhibit_window_system; 2753extern int inhibit_window_system;
2754extern int noninteractive;
2754 2755
2755/* When Emacs is started from the Finder, SELECT always immediately 2756/* When Emacs is started from the Finder, SELECT always immediately
2756 returns as if input is present when file descriptor 0 is polled for 2757 returns as if input is present when file descriptor 0 is polled for
@@ -2767,8 +2768,58 @@ sys_select (n, rfds, wfds, efds, timeout)
2767{ 2768{
2768 if (!inhibit_window_system && rfds && FD_ISSET (0, rfds)) 2769 if (!inhibit_window_system && rfds && FD_ISSET (0, rfds))
2769 return 1; 2770 return 1;
2771 else if (inhibit_window_system || noninteractive)
2772 return select(n, rfds, wfds, efds, timeout);
2770 else 2773 else
2771 return select (n, rfds, wfds, efds, timeout); 2774 {
2775 EMACS_TIME end_time, now;
2776
2777 EMACS_GET_TIME (end_time);
2778 if (timeout)
2779 EMACS_ADD_TIME (end_time, end_time, *timeout);
2780
2781 do
2782 {
2783 int r;
2784 EMACS_TIME one_second;
2785
2786 EMACS_SET_SECS (one_second, 1);
2787 EMACS_SET_USECS (one_second, 0);
2788
2789 if ((r = select (n, rfds, wfds, efds, &one_second)) > 0)
2790 return r;
2791
2792 mac_check_for_quit_char();
2793
2794 EMACS_GET_TIME (now);
2795 EMACS_SUB_TIME (now, end_time, now);
2796 }
2797 while (!timeout || !EMACS_TIME_NEG_P (now));
2798
2799 return 0;
2800 }
2801}
2802
2803#undef read
2804int sys_read (fds, buf, nbyte)
2805 int fds;
2806 char *buf;
2807 unsigned int nbyte;
2808{
2809 SELECT_TYPE rfds;
2810 EMACS_TIME one_second;
2811 int r;
2812
2813 /* Use select to block on IO while still checking for quit_char */
2814 if (!inhibit_window_system && !noninteractive)
2815 {
2816 FD_ZERO (&rfds);
2817 FD_SET (fds, &rfds);
2818 if (sys_select (fds+1, &rfds, 0, 0, NULL) < 0)
2819 return -1;
2820 }
2821
2822 return read (fds, buf, nbyte);
2772} 2823}
2773 2824
2774 2825