diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mac.c | 53 |
1 files changed, 52 insertions, 1 deletions
| @@ -2751,6 +2751,7 @@ and t is the same as `SECONDARY'. */) | |||
| 2751 | #undef select | 2751 | #undef select |
| 2752 | 2752 | ||
| 2753 | extern int inhibit_window_system; | 2753 | extern int inhibit_window_system; |
| 2754 | extern 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 | ||
| 2804 | int 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 | ||