summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Miller <kurt@intricatesoftware.com>2009-07-10 19:14:10 -0400
committerColin Walters <walters@verbum.org>2009-07-14 15:39:26 -0400
commita8b1b8c0b2d3b13bdbb96eb7a9cbea1ea765b6f8 (patch)
tree250257900255e916552bea9b9da4238b00697338
parent951b0c8007fca2a5add7402cb1e260bdefaf0461 (diff)
downloaddbus-a8b1b8c0b2d3b13bdbb96eb7a9cbea1ea765b6f8.tar.gz
Bug 21347 - Don't fail autolaunching if process has SIGCHLD handler
If other code in the process set a global SIGCHLD handler, it will make autolaunching fail spuriously due to waitpid() failing. This fix will temporarily block SIGCHLD delivery. Signed-off-by: Colin Walters <walters@verbum.org> (cherry picked from commit 644fc38b249b490981becda4b2de5261865bba23)
-rw-r--r--dbus/dbus-sysdeps-unix.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index ccb84832..28710f43 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -2860,6 +2860,7 @@ _dbus_get_autolaunch_address (DBusString *address,
int i;
DBusString uuid;
dbus_bool_t retval;
+ sigset_t new_set, old_set;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
retval = FALSE;
@@ -2869,6 +2870,14 @@ _dbus_get_autolaunch_address (DBusString *address,
_DBUS_SET_OOM (error);
return FALSE;
}
+
+ /* We need to block any existing handlers for SIGCHLD temporarily; they
+ * will cause waitpid() below to fail.
+ * https://bugs.freedesktop.org/show_bug.cgi?id=21347
+ */
+ sigemptyset (&new_set);
+ sigaddset (&new_set, SIGCHLD);
+ sigprocmask (SIG_BLOCK, &new_set, &old_set);
if (!_dbus_get_local_machine_uuid_encoded (&uuid))
{
@@ -2963,6 +2972,8 @@ _dbus_get_autolaunch_address (DBusString *address,
for (i = 3; i < maxfds; i++)
close (i);
+ sigprocmask(SIG_SETMASK, &old_set, NULL);
+
execv (DBUS_BINDIR "/dbus-launch", argv);
/* failed, try searching PATH */
@@ -3021,6 +3032,8 @@ _dbus_get_autolaunch_address (DBusString *address,
retval = TRUE;
out:
+ sigprocmask (SIG_SETMASK, &old_set, NULL);
+
if (retval)
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
else