Mercurial > emacs
comparison src/process.c @ 111353:f2cb0d643a91
Backport fix for Bug#6571 from trunk. NOTE: May cause merge conflicts.
* src/keyboard.c (input_available_signal): Declare.
(kbd_buffer_nr_stored): New function.
(kbd_buffer_store_event_hold): If kbd_buffer_nr_stored returns
more than KBD_BUFFER_SIZE/2, stop reding input (Bug#6571).
(kbd_buffer_get_event): If input is suspended and kbd_buffer_nr_stored
returns less than KBD_BUFFER_SIZE/4, resume reding input (Bug#6571).
(tty_read_avail_input): If input is on hold, return.
Don't read more that free slots in kbd_buffer (Bug#6571).
* src/process.c (kbd_is_on_hold): New variable.
(hold_keyboard_input, unhold_keyboard_input, kbd_on_hold_p):
New functions.
(wait_reading_process_output): If kbd_on_hold_p returns non-zero,
select on empty input mask.
(init_process): Initialize kbd_is_on_hold to 0.
* src/process.h (hold_keyboard_input, unhold_keyboard_input)
(kbd_on_hold_p): Declare.
| author | Jan D. <jan.h.d@swipnet.se> |
|---|---|
| date | Mon, 01 Nov 2010 12:30:33 +0100 |
| parents | 4d672e9d91bf |
| children | 1d1b5e1c230b |
comparison
equal
deleted
inserted
replaced
| 111352:9c78ac7dcdf0 | 111353:f2cb0d643a91 |
|---|---|
| 343 /* The largest descriptor currently in use for keyboard input. */ | 343 /* The largest descriptor currently in use for keyboard input. */ |
| 344 static int max_keyboard_desc; | 344 static int max_keyboard_desc; |
| 345 | 345 |
| 346 /* The largest descriptor currently in use for gpm mouse input. */ | 346 /* The largest descriptor currently in use for gpm mouse input. */ |
| 347 static int max_gpm_desc; | 347 static int max_gpm_desc; |
| 348 | |
| 349 /* Non-zero if keyboard input is on hold, zero otherwise. */ | |
| 350 static int kbd_is_on_hold; | |
| 348 | 351 |
| 349 /* Nonzero means delete a process right away if it exits. */ | 352 /* Nonzero means delete a process right away if it exits. */ |
| 350 static int delete_exited_processes; | 353 static int delete_exited_processes; |
| 351 | 354 |
| 352 /* Indexed by descriptor, gives the process (if any) for that descriptor */ | 355 /* Indexed by descriptor, gives the process (if any) for that descriptor */ |
| 4793 SELECT_TYPE Atemp; | 4796 SELECT_TYPE Atemp; |
| 4794 #ifdef NON_BLOCKING_CONNECT | 4797 #ifdef NON_BLOCKING_CONNECT |
| 4795 SELECT_TYPE Ctemp; | 4798 SELECT_TYPE Ctemp; |
| 4796 #endif | 4799 #endif |
| 4797 | 4800 |
| 4798 Atemp = input_wait_mask; | 4801 if (kbd_on_hold_p ()) |
| 4802 FD_ZERO (&Atemp); | |
| 4803 else | |
| 4804 Atemp = input_wait_mask; | |
| 4805 | |
| 4799 IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); | 4806 IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); |
| 4800 | 4807 |
| 4801 EMACS_SET_SECS_USECS (timeout, 0, 0); | 4808 EMACS_SET_SECS_USECS (timeout, 0, 0); |
| 4802 if ((select (max (max (max_process_desc, max_keyboard_desc), | 4809 if ((select (max (max (max_process_desc, max_keyboard_desc), |
| 4803 max_gpm_desc) + 1, | 4810 max_gpm_desc) + 1, |
| 7222 && !FD_ISSET (fd, &non_keyboard_wait_mask)) | 7229 && !FD_ISSET (fd, &non_keyboard_wait_mask)) |
| 7223 return 1; | 7230 return 1; |
| 7224 | 7231 |
| 7225 return 0; | 7232 return 0; |
| 7226 } | 7233 } |
| 7234 | |
| 7235 /* Stop reading input from keyboard sources. */ | |
| 7236 | |
| 7237 void | |
| 7238 hold_keyboard_input (void) | |
| 7239 { | |
| 7240 kbd_is_on_hold = 1; | |
| 7241 } | |
| 7242 | |
| 7243 /* Resume reading input from keyboard sources. */ | |
| 7244 | |
| 7245 void | |
| 7246 unhold_keyboard_input (void) | |
| 7247 { | |
| 7248 kbd_is_on_hold = 0; | |
| 7249 } | |
| 7250 | |
| 7251 /* Return non-zero if keyboard input is on hold, zero otherwise. */ | |
| 7252 | |
| 7253 int | |
| 7254 kbd_on_hold_p (void) | |
| 7255 { | |
| 7256 return kbd_is_on_hold; | |
| 7257 } | |
| 7258 | |
| 7227 | 7259 |
| 7228 /* Enumeration of and access to system processes a-la ps(1). */ | 7260 /* Enumeration of and access to system processes a-la ps(1). */ |
| 7229 | 7261 |
| 7230 DEFUN ("list-system-processes", Flist_system_processes, Slist_system_processes, | 7262 DEFUN ("list-system-processes", Flist_system_processes, Slist_system_processes, |
| 7231 0, 0, 0, | 7263 0, 0, 0, |
| 8037 } | 8069 } |
| 8038 | 8070 |
| 8039 void | 8071 void |
| 8040 init_process () | 8072 init_process () |
| 8041 { | 8073 { |
| 8074 kbd_is_on_hold = 0; | |
| 8042 } | 8075 } |
| 8043 | 8076 |
| 8044 void | 8077 void |
| 8045 syms_of_process () | 8078 syms_of_process () |
| 8046 { | 8079 { |
