comparison src/process.c @ 90851:31beec9ee600

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 751-770) - Update from CVS - Merge from emacs--rel--22 - Update from CVS: lisp/textmodes/sgml-mode.el: Revert last change. - Merge from gnus--rel--5.10 * emacs--rel--22 (patch 18-25) * gnus--rel--5.10 (patch 222-223) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-208
author Miles Bader <miles@gnu.org>
date Thu, 24 May 2007 21:31:10 +0000
parents e6fdae9180d4 9247e9d47488
children 3371fc48749b
comparison
equal deleted inserted replaced
90850:7d184cd91770 90851:31beec9ee600
326 326
327 /* Mask of bits indicating the descriptors that we wait for input on. */ 327 /* Mask of bits indicating the descriptors that we wait for input on. */
328 328
329 static SELECT_TYPE input_wait_mask; 329 static SELECT_TYPE input_wait_mask;
330 330
331 /* Mask that excludes keyboard input descriptor (s). */ 331 /* Mask that excludes keyboard input descriptor(s). */
332 332
333 static SELECT_TYPE non_keyboard_wait_mask; 333 static SELECT_TYPE non_keyboard_wait_mask;
334 334
335 /* Mask that excludes process input descriptor (s). */ 335 /* Mask that excludes process input descriptor(s). */
336 336
337 static SELECT_TYPE non_process_wait_mask; 337 static SELECT_TYPE non_process_wait_mask;
338
339 /* Mask for the gpm mouse input descriptor. */
340
341 static SELECT_TYPE gpm_wait_mask;
338 342
339 #ifdef NON_BLOCKING_CONNECT 343 #ifdef NON_BLOCKING_CONNECT
340 /* Mask of bits indicating the descriptors that we wait for connect to 344 /* Mask of bits indicating the descriptors that we wait for connect to
341 complete on. Once they complete, they are removed from this mask 345 complete on. Once they complete, they are removed from this mask
342 and added to the input_wait_mask and non_keyboard_wait_mask. */ 346 and added to the input_wait_mask and non_keyboard_wait_mask. */
354 /* The largest descriptor currently in use for a process object. */ 358 /* The largest descriptor currently in use for a process object. */
355 static int max_process_desc; 359 static int max_process_desc;
356 360
357 /* The largest descriptor currently in use for keyboard input. */ 361 /* The largest descriptor currently in use for keyboard input. */
358 static int max_keyboard_desc; 362 static int max_keyboard_desc;
363
364 /* The largest descriptor currently in use for gpm mouse input. */
365 static int max_gpm_desc;
359 366
360 /* Nonzero means delete a process right away if it exits. */ 367 /* Nonzero means delete a process right away if it exits. */
361 static int delete_exited_processes; 368 static int delete_exited_processes;
362 369
363 /* Indexed by descriptor, gives the process (if any) for that descriptor */ 370 /* Indexed by descriptor, gives the process (if any) for that descriptor */
4443 FD_CLR (0, &Atemp); 4450 FD_CLR (0, &Atemp);
4444 #endif 4451 #endif
4445 IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); 4452 IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask);
4446 4453
4447 EMACS_SET_SECS_USECS (timeout, 0, 0); 4454 EMACS_SET_SECS_USECS (timeout, 0, 0);
4448 if ((select (max (max_process_desc, max_keyboard_desc) + 1, 4455 if ((select (max (max (max_process_desc, max_keyboard_desc),
4456 max_gpm_desc) + 1,
4449 &Atemp, 4457 &Atemp,
4450 #ifdef NON_BLOCKING_CONNECT 4458 #ifdef NON_BLOCKING_CONNECT
4451 (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0), 4459 (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0),
4452 #else 4460 #else
4453 (SELECT_TYPE *)0, 4461 (SELECT_TYPE *)0,
4588 EMACS_SET_SECS_USECS (timeout, 0, usecs); 4596 EMACS_SET_SECS_USECS (timeout, 0, usecs);
4589 process_output_skip = 0; 4597 process_output_skip = 0;
4590 } 4598 }
4591 #endif 4599 #endif
4592 4600
4593 nfds = select (max (max_process_desc, max_keyboard_desc) + 1, 4601 nfds = select (max (max (max_process_desc, max_keyboard_desc),
4602 max_gpm_desc) + 1,
4594 &Available, 4603 &Available,
4595 #ifdef NON_BLOCKING_CONNECT 4604 #ifdef NON_BLOCKING_CONNECT
4596 (check_connect ? &Connecting : (SELECT_TYPE *)0), 4605 (check_connect ? &Connecting : (SELECT_TYPE *)0),
4597 #else 4606 #else
4598 (SELECT_TYPE *)0, 4607 (SELECT_TYPE *)0,
6882 FD_SET (desc, &non_process_wait_mask); 6891 FD_SET (desc, &non_process_wait_mask);
6883 if (desc > max_keyboard_desc) 6892 if (desc > max_keyboard_desc)
6884 max_keyboard_desc = desc; 6893 max_keyboard_desc = desc;
6885 } 6894 }
6886 6895
6896 static int add_gpm_wait_descriptor_called_flag;
6897
6898 void
6899 add_gpm_wait_descriptor (desc)
6900 int desc;
6901 {
6902 if (! add_gpm_wait_descriptor_called_flag)
6903 FD_CLR (0, &input_wait_mask);
6904 add_gpm_wait_descriptor_called_flag = 1;
6905 FD_SET (desc, &input_wait_mask);
6906 FD_SET (desc, &gpm_wait_mask);
6907 if (desc > max_gpm_desc)
6908 max_gpm_desc = desc;
6909 }
6910
6887 /* From now on, do not expect DESC to give keyboard input. */ 6911 /* From now on, do not expect DESC to give keyboard input. */
6888 6912
6889 void 6913 void
6890 delete_keyboard_wait_descriptor (desc) 6914 delete_keyboard_wait_descriptor (desc)
6891 int desc; 6915 int desc;
6897 FD_CLR (desc, &non_process_wait_mask); 6921 FD_CLR (desc, &non_process_wait_mask);
6898 6922
6899 if (desc == max_keyboard_desc) 6923 if (desc == max_keyboard_desc)
6900 for (fd = 0; fd < lim; fd++) 6924 for (fd = 0; fd < lim; fd++)
6901 if (FD_ISSET (fd, &input_wait_mask) 6925 if (FD_ISSET (fd, &input_wait_mask)
6902 && !FD_ISSET (fd, &non_keyboard_wait_mask)) 6926 && !FD_ISSET (fd, &non_keyboard_wait_mask)
6927 && !FD_ISSET (fd, &gpm_wait_mask))
6903 max_keyboard_desc = fd; 6928 max_keyboard_desc = fd;
6929 }
6930
6931 void
6932 delete_gpm_wait_descriptor (desc)
6933 int desc;
6934 {
6935 int fd;
6936 int lim = max_gpm_desc;
6937
6938 FD_CLR (desc, &input_wait_mask);
6939 FD_CLR (desc, &non_process_wait_mask);
6940
6941 if (desc == max_gpm_desc)
6942 for (fd = 0; fd < lim; fd++)
6943 if (FD_ISSET (fd, &input_wait_mask)
6944 && !FD_ISSET (fd, &non_keyboard_wait_mask)
6945 && !FD_ISSET (fd, &non_process_wait_mask))
6946 max_gpm_desc = fd;
6904 } 6947 }
6905 6948
6906 /* Return nonzero if *MASK has a bit set 6949 /* Return nonzero if *MASK has a bit set
6907 that corresponds to one of the keyboard input descriptors. */ 6950 that corresponds to one of the keyboard input descriptors. */
6908 6951