diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 7ecee63..13e7235 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -406,6 +406,7 @@ static pid_t bus_pid_to_kill = -1; static void kill_bus(void) { + if (bus_pid_to_kill == -1) return; verbose ("Killing message bus and exiting babysitter\n"); kill (bus_pid_to_kill, SIGTERM); sleep (3); @@ -1273,7 +1274,9 @@ main (int argc, char **argv) exit (1); } - 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 = val; close (bus_pid_to_launcher_pipe[READ_END]); @@ -1291,7 +1294,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) {