Mercurial > emacs
comparison src/process.c @ 4682:c4d471244116
(keyboard_descriptor): New variable.
(wait_reading_process_input, init_keyboard): Use it.
Also call change_input_fd.
(change_keyboard_wait_descriptor): New function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 08 Sep 1993 17:53:11 +0000 |
parents | 76f242eb1fa8 |
children | 1fc792473491 |
comparison
equal
deleted
inserted
replaced
4681:6945d02dd725 | 4682:c4d471244116 |
---|---|
71 #include "termhooks.h" | 71 #include "termhooks.h" |
72 #include "termopts.h" | 72 #include "termopts.h" |
73 #include "commands.h" | 73 #include "commands.h" |
74 #include "frame.h" | 74 #include "frame.h" |
75 | 75 |
76 Lisp_Object Qprocessp; | |
76 Lisp_Object Qrun, Qstop, Qsignal, Qopen, Qclosed; | 77 Lisp_Object Qrun, Qstop, Qsignal, Qopen, Qclosed; |
77 /* Qexit is declared and initialized in eval.c. */ | 78 /* Qexit is declared and initialized in eval.c. */ |
78 | 79 |
79 /* a process object is a network connection when its childp field is neither | 80 /* a process object is a network connection when its childp field is neither |
80 Qt nor Qnil but is instead a string (name of foreign host we | 81 Qt nor Qnil but is instead a string (name of foreign host we |
148 #endif | 149 #endif |
149 #endif /* VMS */ | 150 #endif /* VMS */ |
150 | 151 |
151 /* t means use pty, nil means use a pipe, | 152 /* t means use pty, nil means use a pipe, |
152 maybe other values to come. */ | 153 maybe other values to come. */ |
153 Lisp_Object Vprocess_connection_type; | 154 static Lisp_Object Vprocess_connection_type; |
154 | 155 |
155 #ifdef SKTPAIR | 156 #ifdef SKTPAIR |
156 #ifndef HAVE_SOCKETS | 157 #ifndef HAVE_SOCKETS |
157 #include <sys/socket.h> | 158 #include <sys/socket.h> |
158 #endif | 159 #endif |
159 #endif /* SKTPAIR */ | 160 #endif /* SKTPAIR */ |
160 | 161 |
161 /* Number of events of change of status of a process. */ | 162 /* Number of events of change of status of a process. */ |
162 int process_tick; | 163 static int process_tick; |
163 | 164 |
164 /* Number of events for which the user or sentinel has been notified. */ | 165 /* Number of events for which the user or sentinel has been notified. */ |
165 int update_tick; | 166 static int update_tick; |
166 | 167 |
167 #ifdef FD_SET | 168 #ifdef FD_SET |
168 /* We could get this from param.h, but better not to depend on finding that. | 169 /* We could get this from param.h, but better not to depend on finding that. |
169 And better not to risk that it might define other symbols used in this | 170 And better not to risk that it might define other symbols used in this |
170 file. */ | 171 file. */ |
185 #define FD_ZERO(p) (*(p) = 0) | 186 #define FD_ZERO(p) (*(p) = 0) |
186 #endif /* no FD_SET */ | 187 #endif /* no FD_SET */ |
187 | 188 |
188 /* Mask of bits indicating the descriptors that we wait for input on */ | 189 /* Mask of bits indicating the descriptors that we wait for input on */ |
189 | 190 |
190 SELECT_TYPE input_wait_mask; | 191 static SELECT_TYPE input_wait_mask; |
191 | 192 |
192 int delete_exited_processes; | 193 /* Descriptor to use for keyboard input. */ |
194 static int keyboard_descriptor; | |
195 | |
196 /* Nonzero means delete a process right away if it exits. */ | |
197 static int delete_exited_processes; | |
193 | 198 |
194 /* Indexed by descriptor, gives the process (if any) for that descriptor */ | 199 /* Indexed by descriptor, gives the process (if any) for that descriptor */ |
195 Lisp_Object chan_process[MAXDESC]; | 200 static Lisp_Object chan_process[MAXDESC]; |
196 | 201 |
197 /* Alist of elements (NAME . PROCESS) */ | 202 /* Alist of elements (NAME . PROCESS) */ |
198 Lisp_Object Vprocess_alist; | 203 static Lisp_Object Vprocess_alist; |
199 | |
200 Lisp_Object Qprocessp; | |
201 | |
202 Lisp_Object get_process (); | |
203 | 204 |
204 /* Buffered-ahead input char from process, indexed by channel. | 205 /* Buffered-ahead input char from process, indexed by channel. |
205 -1 means empty (no char is buffered). | 206 -1 means empty (no char is buffered). |
206 Used on sys V where the only way to tell if there is any | 207 Used on sys V where the only way to tell if there is any |
207 output from the process is to read at least one char. | 208 output from the process is to read at least one char. |
208 Always -1 on systems that support FIONREAD. */ | 209 Always -1 on systems that support FIONREAD. */ |
209 | 210 |
210 int proc_buffered_char[MAXDESC]; | 211 static int proc_buffered_char[MAXDESC]; |
212 | |
213 static Lisp_Object get_process (); | |
211 | 214 |
212 /* Compute the Lisp form of the process status, p->status, from | 215 /* Compute the Lisp form of the process status, p->status, from |
213 the numeric status that was returned by `wait'. */ | 216 the numeric status that was returned by `wait'. */ |
214 | 217 |
215 Lisp_Object status_convert (); | 218 Lisp_Object status_convert (); |
1751 Available = input_wait_mask; | 1754 Available = input_wait_mask; |
1752 /* We used to have && wait_for_cell == 0 | 1755 /* We used to have && wait_for_cell == 0 |
1753 but that led to lossage handling selection_request events: | 1756 but that led to lossage handling selection_request events: |
1754 within one, we would start to handle another. */ | 1757 within one, we would start to handle another. */ |
1755 if (! XINT (read_kbd)) | 1758 if (! XINT (read_kbd)) |
1756 FD_CLR (0, &Available); | 1759 FD_CLR (keyboard_descriptor, &Available); |
1757 | 1760 |
1758 /* If frame size has changed or the window is newly mapped, | 1761 /* If frame size has changed or the window is newly mapped, |
1759 redisplay now, before we start to wait. There is a race | 1762 redisplay now, before we start to wait. There is a race |
1760 condition here; if a SIGIO arrives between now and the select | 1763 condition here; if a SIGIO arrives between now and the select |
1761 and indicates that a frame is trashed, the select may block | 1764 and indicates that a frame is trashed, the select may block |
1814 } | 1817 } |
1815 else | 1818 else |
1816 error("select error: %s", sys_errlist[xerrno]); | 1819 error("select error: %s", sys_errlist[xerrno]); |
1817 } | 1820 } |
1818 #if defined(sun) && !defined(USG5_4) | 1821 #if defined(sun) && !defined(USG5_4) |
1819 else if (nfds > 0 && FD_ISSET (0, &Available) && interrupt_input) | 1822 else if (nfds > 0 && FD_ISSET (keyboard_descriptor, &Available) |
1823 && interrupt_input) | |
1820 /* System sometimes fails to deliver SIGIO. | 1824 /* System sometimes fails to deliver SIGIO. |
1821 | 1825 |
1822 David J. Mackenzie says that Emacs doesn't compile under | 1826 David J. Mackenzie says that Emacs doesn't compile under |
1823 Solaris if this code is enabled, thus the USG5_4 in the CPP | 1827 Solaris if this code is enabled, thus the USG5_4 in the CPP |
1824 conditional. "I haven't noticed any ill effects so far. | 1828 conditional. "I haven't noticed any ill effects so far. |
1849 /* If we think we have keyboard input waiting, but didn't get SIGIO | 1853 /* If we think we have keyboard input waiting, but didn't get SIGIO |
1850 go read it. This can happen with X on BSD after logging out. | 1854 go read it. This can happen with X on BSD after logging out. |
1851 In that case, there really is no input and no SIGIO, | 1855 In that case, there really is no input and no SIGIO, |
1852 but select says there is input. */ | 1856 but select says there is input. */ |
1853 | 1857 |
1854 if (XINT (read_kbd) && interrupt_input && (FD_ISSET (fileno (stdin), &Available))) | 1858 if (XINT (read_kbd) && interrupt_input |
1859 && (FD_ISSET (keyboard_descriptor, &Available))) | |
1855 kill (0, SIGIO); | 1860 kill (0, SIGIO); |
1856 #endif | 1861 #endif |
1857 | 1862 |
1858 if (! wait_proc) | 1863 if (! wait_proc) |
1859 got_some_input |= nfds > 0; | 1864 got_some_input |= nfds > 0; |
2928 #endif | 2933 #endif |
2929 signal (SIGCHLD, sigchld_handler); | 2934 signal (SIGCHLD, sigchld_handler); |
2930 #endif | 2935 #endif |
2931 | 2936 |
2932 FD_ZERO (&input_wait_mask); | 2937 FD_ZERO (&input_wait_mask); |
2933 FD_SET (0, &input_wait_mask); | 2938 |
2939 keyboard_descriptor = 0; | |
2940 FD_SET (keyboard_descriptor, &input_wait_mask); | |
2941 | |
2934 Vprocess_alist = Qnil; | 2942 Vprocess_alist = Qnil; |
2935 for (i = 0; i < MAXDESC; i++) | 2943 for (i = 0; i < MAXDESC; i++) |
2936 { | 2944 { |
2937 chan_process[i] = Qnil; | 2945 chan_process[i] = Qnil; |
2938 proc_buffered_char[i] = -1; | 2946 proc_buffered_char[i] = -1; |
2939 } | 2947 } |
2948 } | |
2949 | |
2950 /* From now on, assume keyboard input comes from descriptor DESC. */ | |
2951 | |
2952 void | |
2953 change_keyboard_wait_descriptor (desc) | |
2954 int desc; | |
2955 { | |
2956 FD_CLR (keyboard_descriptor, &input_wait_mask); | |
2957 keyboard_descriptor = desc; | |
2958 FD_SET (keyboard_descriptor, &input_wait_mask); | |
2940 } | 2959 } |
2941 | 2960 |
2942 syms_of_process () | 2961 syms_of_process () |
2943 { | 2962 { |
2944 #ifdef HAVE_SOCKETS | 2963 #ifdef HAVE_SOCKETS |