diff options
author | Kurt Miller <kurt@intricatesoftware.com> | 2009-07-10 19:14:10 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2009-07-10 19:19:28 -0400 |
commit | 644fc38b249b490981becda4b2de5261865bba23 (patch) | |
tree | 2bf3a9990c842ccaa8282840a6d07e4343177f95 /dbus | |
parent | 3f070088232f82fafce97c4fb3015da098fe00bf (diff) |
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>
Diffstat (limited to 'dbus')
-rw-r--r-- | dbus/dbus-sysdeps-unix.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 29d234a4..5221a1a8 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -2866,6 +2866,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; @@ -2875,6 +2876,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)) { @@ -2969,6 +2978,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 */ @@ -3027,6 +3038,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 |