aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/src/process.c b/src/process.c
index 46385fa096b..a873dd0cdb2 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4528,10 +4528,10 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4528 } 4528 }
4529#endif 4529#endif
4530 4530
4531#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) 4531#if defined (HAVE_NS)
4532 nfds = xg_select 4532 nfds = ns_select
4533#elif defined (HAVE_NS) 4533#elif defined (HAVE_GLIB)
4534 nfds = ns_select 4534 nfds = xg_select
4535#else 4535#else
4536 nfds = pselect 4536 nfds = pselect
4537#endif 4537#endif
@@ -6100,6 +6100,12 @@ process has been transmitted to the serial port. */)
6100 might inadvertently reap a GTK-created process that happened to 6100 might inadvertently reap a GTK-created process that happened to
6101 have the same process ID. */ 6101 have the same process ID. */
6102 6102
6103/* LIB_CHILD_HANDLER is a SIGCHLD handler that Emacs calls while doing
6104 its own SIGCHLD handling. On POSIXish systems, glib needs this to
6105 keep track of its own children. The default handler does nothing. */
6106static void dummy_handler (int sig) {}
6107static signal_handler_t volatile lib_child_handler = dummy_handler;
6108
6103/* Handle a SIGCHLD signal by looking for known child processes of 6109/* Handle a SIGCHLD signal by looking for known child processes of
6104 Emacs whose status have changed. For each one found, record its 6110 Emacs whose status have changed. For each one found, record its
6105 new status. 6111 new status.
@@ -6159,7 +6165,8 @@ handle_child_signal (int sig)
6159 struct Lisp_Process *p = XPROCESS (proc); 6165 struct Lisp_Process *p = XPROCESS (proc);
6160 int status; 6166 int status;
6161 6167
6162 if (p->alive && child_status_changed (p->pid, &status, WUNTRACED)) 6168 if (p->alive
6169 && child_status_changed (p->pid, &status, WUNTRACED | WCONTINUED))
6163 { 6170 {
6164 /* Change the status of the process that was found. */ 6171 /* Change the status of the process that was found. */
6165 p->tick = ++process_tick; 6172 p->tick = ++process_tick;
@@ -6183,6 +6190,8 @@ handle_child_signal (int sig)
6183 } 6190 }
6184 } 6191 }
6185 } 6192 }
6193
6194 lib_child_handler (sig);
6186} 6195}
6187 6196
6188static void 6197static void
@@ -7028,6 +7037,21 @@ integer or floating point values.
7028 return system_process_attributes (pid); 7037 return system_process_attributes (pid);
7029} 7038}
7030 7039
7040#ifndef NS_IMPL_GNUSTEP
7041static
7042#endif
7043void
7044catch_child_signal (void)
7045{
7046 struct sigaction action, old_action;
7047 emacs_sigaction_init (&action, deliver_child_signal);
7048 sigaction (SIGCHLD, &action, &old_action);
7049 eassert (! (old_action.sa_flags & SA_SIGINFO));
7050 if (old_action.sa_handler != SIG_DFL && old_action.sa_handler != SIG_IGN
7051 && old_action.sa_handler != deliver_child_signal)
7052 lib_child_handler = old_action.sa_handler;
7053}
7054
7031 7055
7032/* This is not called "init_process" because that is the name of a 7056/* This is not called "init_process" because that is the name of a
7033 Mach system call, so it would cause problems on Darwin systems. */ 7057 Mach system call, so it would cause problems on Darwin systems. */
@@ -7043,9 +7067,13 @@ init_process_emacs (void)
7043 if (! noninteractive || initialized) 7067 if (! noninteractive || initialized)
7044#endif 7068#endif
7045 { 7069 {
7046 struct sigaction action; 7070#if defined HAVE_GLIB && !defined WINDOWSNT
7047 emacs_sigaction_init (&action, deliver_child_signal); 7071 /* Tickle glib's child-handling code. Ask glib to wait for Emacs itself;
7048 sigaction (SIGCHLD, &action, 0); 7072 this should always fail, but is enough to initialize glib's
7073 private SIGCHLD handler. */
7074 g_source_unref (g_child_watch_source_new (getpid ()));
7075#endif
7076 catch_child_signal ();
7049 } 7077 }
7050 7078
7051 FD_ZERO (&input_wait_mask); 7079 FD_ZERO (&input_wait_mask);