comparison src/process.c @ 72220:059876b57133

(wait_reading_process_output_unwind): New function. Restores waiting_for_user_input_p to saved value. (wait_reading_process_output): Unwind protect waiting_for_user_input_p instead of save/restore old value on stack.
author Kim F. Storm <storm@cua.dk>
date Tue, 01 Aug 2006 00:13:08 +0000
parents f3f2486cf6bc
children a4cd71253e87 858cb33ae39d
comparison
equal deleted inserted replaced
72219:efb471b59acc 72220:059876b57133
4156 This is also used in record_asynch_buffer_change. 4156 This is also used in record_asynch_buffer_change.
4157 For that purpose, this must be 0 4157 For that purpose, this must be 0
4158 when not inside wait_reading_process_output. */ 4158 when not inside wait_reading_process_output. */
4159 static int waiting_for_user_input_p; 4159 static int waiting_for_user_input_p;
4160 4160
4161 static Lisp_Object
4162 wait_reading_process_output_unwind (data)
4163 Lisp_Object data;
4164 {
4165 waiting_for_user_input_p = XINT (data);
4166 return Qnil;
4167 }
4168
4161 /* This is here so breakpoints can be put on it. */ 4169 /* This is here so breakpoints can be put on it. */
4162 static void 4170 static void
4163 wait_reading_process_output_1 () 4171 wait_reading_process_output_1 ()
4164 { 4172 {
4165 } 4173 }
4238 int xerrno; 4246 int xerrno;
4239 Lisp_Object proc; 4247 Lisp_Object proc;
4240 EMACS_TIME timeout, end_time; 4248 EMACS_TIME timeout, end_time;
4241 int wait_channel = -1; 4249 int wait_channel = -1;
4242 int got_some_input = 0; 4250 int got_some_input = 0;
4243 /* Either nil or a cons cell, the car of which is of interest and 4251 int count = SPECPDL_INDEX ();
4244 may be changed outside of this routine. */
4245 int saved_waiting_for_user_input_p = waiting_for_user_input_p;
4246 4252
4247 FD_ZERO (&Available); 4253 FD_ZERO (&Available);
4248 #ifdef NON_BLOCKING_CONNECT 4254 #ifdef NON_BLOCKING_CONNECT
4249 FD_ZERO (&Connecting); 4255 FD_ZERO (&Connecting);
4250 #endif 4256 #endif
4251 4257
4252 /* If wait_proc is a process to watch, set wait_channel accordingly. */ 4258 /* If wait_proc is a process to watch, set wait_channel accordingly. */
4253 if (wait_proc != NULL) 4259 if (wait_proc != NULL)
4254 wait_channel = XINT (wait_proc->infd); 4260 wait_channel = XINT (wait_proc->infd);
4255 4261
4262 record_unwind_protect (wait_reading_process_output_unwind,
4263 make_number (waiting_for_user_input_p));
4256 waiting_for_user_input_p = read_kbd; 4264 waiting_for_user_input_p = read_kbd;
4257 4265
4258 /* Since we may need to wait several times, 4266 /* Since we may need to wait several times,
4259 compute the absolute time to return at. */ 4267 compute the absolute time to return at. */
4260 if (time_limit || microsecs) 4268 if (time_limit || microsecs)
4877 } 4885 }
4878 #endif /* NON_BLOCKING_CONNECT */ 4886 #endif /* NON_BLOCKING_CONNECT */
4879 } /* end for each file descriptor */ 4887 } /* end for each file descriptor */
4880 } /* end while exit conditions not met */ 4888 } /* end while exit conditions not met */
4881 4889
4882 waiting_for_user_input_p = saved_waiting_for_user_input_p; 4890 unbind_to (count, Qnil);
4883 4891
4884 /* If calling from keyboard input, do not quit 4892 /* If calling from keyboard input, do not quit
4885 since we want to return C-g as an input character. 4893 since we want to return C-g as an input character.
4886 Otherwise, do pending quit if requested. */ 4894 Otherwise, do pending quit if requested. */
4887 if (read_kbd >= 0) 4895 if (read_kbd >= 0)