summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-06-05 10:04:13 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2013-06-05 10:04:13 -0700
commitf019a684847950c24f5dd8ee8cfdd40d3511ba83 (patch)
tree1226d99c68968dd9b51cc0c15eba0e3c4ce670d0 /src
parent28f5da6df34eb64677e25afd001c1f48b012aec7 (diff)
downloademacs-f019a684847950c24f5dd8ee8cfdd40d3511ba83.tar.gz
emacs-f019a684847950c24f5dd8ee8cfdd40d3511ba83.tar.bz2
emacs-f019a684847950c24f5dd8ee8cfdd40d3511ba83.zip
Chain glib's SIGCHLD handler from Emacs's (Bug#14474).
* process.c (dummy_handler): New function. (lib_child_handler): New static var. (handle_child_signal): Invoke it. (catch_child_signal): If a library has set up a signal handler, save it into lib_child_handler. (init_process_emacs): If using glib and not on Windows, tickle glib's child-handling code so that it initializes its private SIGCHLD handler. * syssignal.h (SA_SIGINFO): Default to 0. * xterm.c (x_term_init): Remove D-bus hack that I installed on May 31; it should no longer be needed now.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/process.c21
-rw-r--r--src/syssignal.h4
-rw-r--r--src/xterm.c7
4 files changed, 37 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 67b1b482f3f..ac0563c6bdd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,17 @@
+2013-06-05 Paul Eggert <eggert@cs.ucla.edu>
+
+ Chain glib's SIGCHLD handler from Emacs's (Bug#14474).
+ * process.c (dummy_handler): New function.
+ (lib_child_handler): New static var.
+ (handle_child_signal): Invoke it.
+ (catch_child_signal): If a library has set up a signal handler,
+ save it into lib_child_handler.
+ (init_process_emacs): If using glib and not on Windows, tickle glib's
+ child-handling code so that it initializes its private SIGCHLD handler.
+ * syssignal.h (SA_SIGINFO): Default to 0.
+ * xterm.c (x_term_init): Remove D-bus hack that I installed on May
+ 31; it should no longer be needed now.
+
2013-06-05 Michael Albinus <michael.albinus@gmx.de>
* emacs.c (main) [HAVE_GFILENOTIFY]: Call globals_of_gfilenotify.
diff --git a/src/process.c b/src/process.c
index 33035078df9..6ae02494d36 100644
--- a/src/process.c
+++ b/src/process.c
@@ -6100,6 +6100,12 @@ process has been transmitted to the serial port. */)
might inadvertently reap a GTK-created process that happened to
have the same process ID. */
+/* LIB_CHILD_HANDLER is a SIGCHLD handler that Emacs calls while doing
+ its own SIGCHLD handling. On POSIXish systems, glib needs this to
+ keep track of its own children. The default handler does nothing. */
+static void dummy_handler (int sig) {}
+static signal_handler_t volatile lib_child_handler = dummy_handler;
+
/* Handle a SIGCHLD signal by looking for known child processes of
Emacs whose status have changed. For each one found, record its
new status.
@@ -6184,6 +6190,8 @@ handle_child_signal (int sig)
}
}
}
+
+ lib_child_handler (sig);
}
static void
@@ -7035,9 +7043,13 @@ static
void
catch_child_signal (void)
{
- struct sigaction action;
+ struct sigaction action, old_action;
emacs_sigaction_init (&action, deliver_child_signal);
- sigaction (SIGCHLD, &action, 0);
+ sigaction (SIGCHLD, &action, &old_action);
+ eassert (! (old_action.sa_flags & SA_SIGINFO));
+ if (old_action.sa_handler != SIG_DFL && old_action.sa_handler != SIG_IGN
+ && old_action.sa_handler != deliver_child_signal)
+ lib_child_handler = old_action.sa_handler;
}
@@ -7055,6 +7067,11 @@ init_process_emacs (void)
if (! noninteractive || initialized)
#endif
{
+#if defined HAVE_GLIB && !defined WINDOWSNT
+ /* Tickle glib's child-handling code so that it initializes its
+ private SIGCHLD handler. */
+ g_source_unref (g_child_watch_source_new (0));
+#endif
catch_child_signal ();
}
diff --git a/src/syssignal.h b/src/syssignal.h
index d7399c6cb8c..45ea8f1af3c 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -50,6 +50,10 @@ char const *safe_strsignal (int) ATTRIBUTE_CONST;
# define NSIG NSIG_MINIMUM
#endif
+#ifndef SA_SIGINFO
+# define SA_SIGINFO 0
+#endif
+
#ifndef emacs_raise
# define emacs_raise(sig) raise (sig)
#endif
diff --git a/src/xterm.c b/src/xterm.c
index 7038de7039f..7505aa3936b 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9897,13 +9897,6 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
XSetLocaleModifiers ("");
- /* If D-Bus is not already configured, inhibit D-Bus autolaunch,
- as autolaunch can mess up Emacs's SIGCHLD handler.
- FIXME: Rewrite subprocess handlers to use glib's child watchers.
- See Bug#14474. */
- if (! egetenv ("DBUS_SESSION_BUS_ADDRESS"))
- xputenv ("DBUS_SESSION_BUS_ADDRESS=unix:path=/dev/null");
-
/* Emacs can only handle core input events, so make sure
Gtk doesn't use Xinput or Xinput2 extensions. */
xputenv ("GDK_CORE_DEVICE_EVENTS=1");