Mercurial > emacs
comparison src/process.c @ 588:f284b1a71fb3
*** empty log message ***
| author | Jim Blandy <jimb@redhat.com> |
|---|---|
| date | Wed, 18 Mar 1992 20:22:31 +0000 |
| parents | a4591b4d5435 |
| children | 63a8e7b3c547 |
comparison
equal
deleted
inserted
replaced
| 587:1c2d1836941a | 588:f284b1a71fb3 |
|---|---|
| 20 | 20 |
| 21 #include <signal.h> | 21 #include <signal.h> |
| 22 | 22 |
| 23 #include "config.h" | 23 #include "config.h" |
| 24 | 24 |
| 25 /* This file is split into two parts by the following preprocessor | |
| 26 conditional. The 'then' clause contains all of the support for | |
| 27 asynchronous subprocesses. The 'else' clause contains stub | |
| 28 versions of some of the asynchronous subprocess routines that are | |
| 29 often called elsewhere in Emacs, so we don't have to #ifdef the | |
| 30 sections that call them. */ | |
| 31 | |
| 32 | |
| 25 #ifdef subprocesses | 33 #ifdef subprocesses |
| 26 /* The entire file is within this conditional */ | |
| 27 | 34 |
| 28 #include <stdio.h> | 35 #include <stdio.h> |
| 29 #include <errno.h> | 36 #include <errno.h> |
| 30 #include <setjmp.h> | 37 #include <setjmp.h> |
| 31 #include <sys/types.h> /* some typedefs are used in sys/file.h */ | 38 #include <sys/types.h> /* some typedefs are used in sys/file.h */ |
| 1741 redisplay_preserve_echo_area (); | 1748 redisplay_preserve_echo_area (); |
| 1742 | 1749 |
| 1743 if (read_kbd && detect_input_pending ()) | 1750 if (read_kbd && detect_input_pending ()) |
| 1744 nfds = 0; | 1751 nfds = 0; |
| 1745 else | 1752 else |
| 1746 #ifdef AIX | |
| 1747 nfds = select (MAXDESC, &Available, 0, 0, &timeout); | 1753 nfds = select (MAXDESC, &Available, 0, 0, &timeout); |
| 1748 #else | 1754 |
| 1749 #ifdef HPUX | |
| 1750 nfds = select (MAXDESC, &Available, 0, 0, &timeout); | |
| 1751 #else | |
| 1752 nfds = select (MAXDESC, &Available, 0, 0, &timeout); | |
| 1753 #endif | |
| 1754 #endif | |
| 1755 xerrno = errno; | 1755 xerrno = errno; |
| 1756 | 1756 |
| 1757 /* Make C-g and alarm signals set flags again */ | 1757 /* Make C-g and alarm signals set flags again */ |
| 1758 clear_waiting_for_input (); | 1758 clear_waiting_for_input (); |
| 1759 | 1759 |
| 2882 defsubr (&Ssignal_process); | 2882 defsubr (&Ssignal_process); |
| 2883 defsubr (&Swaiting_for_user_input_p); | 2883 defsubr (&Swaiting_for_user_input_p); |
| 2884 /* defsubr (&Sprocess_connection); */ | 2884 /* defsubr (&Sprocess_connection); */ |
| 2885 } | 2885 } |
| 2886 | 2886 |
| 2887 #endif /* subprocesses */ | 2887 |
| 2888 #else /* not subprocesses */ | |
| 2889 | |
| 2890 #include <sys/types.h> | |
| 2891 #include <errno.h> | |
| 2892 | |
| 2893 #include "lisp.h" | |
| 2894 #include "systime.h" | |
| 2895 #include "termopts.h" | |
| 2896 | |
| 2897 extern int screen_garbaged; | |
| 2898 | |
| 2899 | |
| 2900 /* As described above, except assuming that there are no subprocesses: | |
| 2901 | |
| 2902 Wait for timeout to elapse and/or keyboard input to be available. | |
| 2903 | |
| 2904 time_limit is: | |
| 2905 timeout in seconds, or | |
| 2906 zero for no limit, or | |
| 2907 -1 means gobble data immediately available but don't wait for any. | |
| 2908 | |
| 2909 read_kbd is: | |
| 2910 0 to ignore keyboard input, or | |
| 2911 1 to return when input is available, or | |
| 2912 -1 means caller will actually read the input, so don't throw to | |
| 2913 the quit handler. | |
| 2914 We know that read_kbd will never be a Lisp_Process, since | |
| 2915 `subprocesses' isn't defined. | |
| 2916 | |
| 2917 do_display != 0 means redisplay should be done to show subprocess | |
| 2918 output that arrives. This version of the function ignores it. | |
| 2919 | |
| 2920 If read_kbd is a pointer to a struct Lisp_Process, then the | |
| 2921 function returns true iff we received input from that process | |
| 2922 before the timeout elapsed. | |
| 2923 Otherwise, return true iff we recieved input from any process. */ | |
| 2924 | |
| 2925 int | |
| 2926 wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |
| 2927 int time_limit, microsecs, read_kbd, do_display; | |
| 2928 { | |
| 2929 EMACS_TIME end_time, timeout, *timeout_p; | |
| 2930 int waitchannels; | |
| 2931 | |
| 2932 /* What does time_limit really mean? */ | |
| 2933 if (time_limit || microsecs) | |
| 2934 { | |
| 2935 /* It's not infinite. */ | |
| 2936 timeout_p = &timeout; | |
| 2937 | |
| 2938 if (time_limit == -1) | |
| 2939 /* In fact, it's zero. */ | |
| 2940 EMACS_SET_SECS_USECS (timeout, 0, 0); | |
| 2941 else | |
| 2942 EMACS_SET_SECS_USECS (timeout, time_limit, microsecs); | |
| 2943 | |
| 2944 /* How far in the future is that? */ | |
| 2945 EMACS_GET_TIME (end_time); | |
| 2946 EMACS_ADD_TIME (end_time, end_time, timeout); | |
| 2947 } | |
| 2948 else | |
| 2949 /* It's infinite. */ | |
| 2950 timeout_p = 0; | |
| 2951 | |
| 2952 /* Turn off periodic alarms (in case they are in use) | |
| 2953 because the select emulator uses alarms. */ | |
| 2954 stop_polling (); | |
| 2955 | |
| 2956 for (;;) | |
| 2957 { | |
| 2958 int nfds; | |
| 2959 | |
| 2960 waitchannels = read_kbd ? 1 : 0; | |
| 2961 | |
| 2962 /* If calling from keyboard input, do not quit | |
| 2963 since we want to return C-g as an input character. | |
| 2964 Otherwise, do pending quit if requested. */ | |
| 2965 if (read_kbd >= 0) | |
| 2966 QUIT; | |
| 2967 | |
| 2968 if (timeout_p) | |
| 2969 { | |
| 2970 EMACS_GET_TIME (*timeout_p); | |
| 2971 EMACS_SUB_TIME (*timeout_p, end_time, *timeout_p); | |
| 2972 if (EMACS_TIME_NEG_P (*timeout_p)) | |
| 2973 break; | |
| 2974 } | |
| 2975 | |
| 2976 /* Cause C-g and alarm signals to take immediate action, | |
| 2977 and cause input available signals to zero out timeout. */ | |
| 2978 if (read_kbd < 0) | |
| 2979 set_waiting_for_input (&timeout); | |
| 2980 | |
| 2981 /* If a screen has been newly mapped and needs updating, | |
| 2982 reprocess its display stuff. */ | |
| 2983 if (screen_garbaged) | |
| 2984 redisplay_preserve_echo_area (); | |
| 2985 | |
| 2986 if (read_kbd && detect_input_pending ()) | |
| 2987 nfds = 0; | |
| 2988 else | |
| 2989 nfds = select (1, &waitchannels, 0, 0, timeout_p); | |
| 2990 | |
| 2991 /* Make C-g and alarm signals set flags again */ | |
| 2992 clear_waiting_for_input (); | |
| 2993 | |
| 2994 /* If we woke up due to SIGWINCH, actually change size now. */ | |
| 2995 do_pending_window_change (); | |
| 2996 | |
| 2997 if (nfds == -1) | |
| 2998 { | |
| 2999 /* If the system call was interrupted, then go around the | |
| 3000 loop again. */ | |
| 3001 if (errno == EINTR) | |
| 3002 waitchannels = 0; | |
| 3003 } | |
| 3004 #ifdef sun | |
| 3005 else if (nfds > 0 && (waitchannels & 1) && interrupt_input) | |
| 3006 /* System sometimes fails to deliver SIGIO. */ | |
| 3007 kill (getpid (), SIGIO); | |
| 3008 #endif | |
| 3009 if (read_kbd && interrupt_input && (waitchannels & 1)) | |
| 3010 kill (0, SIGIO); | |
| 3011 | |
| 3012 /* If we have timed out (nfds == 0) or found some input (nfds > 0), | |
| 3013 we should exit. */ | |
| 3014 if (nfds >= 0) | |
| 3015 break; | |
| 3016 } | |
| 3017 | |
| 3018 return 0; | |
| 3019 } | |
| 3020 | |
| 3021 | |
| 3022 DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0, | |
| 3023 "Return the (or, a) process associated with BUFFER.\n\ | |
| 3024 This copy of Emacs has not been built to support subprocesses, so this\n\ | |
| 3025 function always returns nil.") | |
| 3026 (name) | |
| 3027 register Lisp_Object name; | |
| 3028 { | |
| 3029 return Qnil; | |
| 3030 } | |
| 3031 | |
| 3032 /* Kill all processes associated with `buffer'. | |
| 3033 If `buffer' is nil, kill all processes. | |
| 3034 Since we have no subprocesses, this does nothing. */ | |
| 3035 | |
| 3036 kill_buffer_processes (buffer) | |
| 3037 Lisp_Object buffer; | |
| 3038 { | |
| 3039 } | |
| 3040 | |
| 3041 init_process () | |
| 3042 { | |
| 3043 } | |
| 3044 | |
| 3045 syms_of_process () | |
| 3046 { | |
| 3047 defsubr (&Sget_buffer_process); | |
| 3048 } | |
| 3049 | |
| 3050 | |
| 3051 #endif /* not subprocesses */ |
