summaryrefslogtreecommitdiff
path: root/tools/dbus-launch.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/dbus-launch.c')
-rw-r--r--tools/dbus-launch.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c
index 7ecee63e..41a20e83 100644
--- a/tools/dbus-launch.c
+++ b/tools/dbus-launch.c
@@ -406,6 +406,9 @@ static pid_t bus_pid_to_kill = -1;
static void
kill_bus(void)
{
+ if (bus_pid_to_kill <= 0)
+ return;
+
verbose ("Killing message bus and exiting babysitter\n");
kill (bus_pid_to_kill, SIGTERM);
sleep (3);
@@ -533,7 +536,7 @@ kill_bus_when_session_ends (void)
if (tty_fd < 0 && x_fd < 0)
{
fprintf (stderr, "No terminal on standard input and no X display; cannot attach message bus to session lifetime\n");
- exit (1);
+ kill_bus_and_exit (1);
}
while (TRUE)
@@ -1275,6 +1278,10 @@ main (int argc, char **argv)
bus_pid = val;
+ /* Have to initialize bus_pid_to_kill ASAP, so that the
+ X error callback can kill it if an error happens. */
+ bus_pid_to_kill = bus_pid;
+
close (bus_pid_to_launcher_pipe[READ_END]);
#ifdef DBUS_ENABLE_X11_AUTOLAUNCH
@@ -1291,7 +1298,6 @@ main (int argc, char **argv)
{
char *address = NULL;
/* another window got added. Return its address */
- bus_pid_to_kill = bus_pid;
if (x11_get_address (&address, &bus_pid, &wid)
&& address != NULL)
{