diff options
Diffstat (limited to 'tools/dbus-launch.c')
-rw-r--r-- | tools/dbus-launch.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 1b655027..800c1123 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -169,7 +169,7 @@ usage (int ecode) { fprintf (stderr, "dbus-launch [--version] [--help] [--sh-syntax]" " [--csh-syntax] [--auto-syntax] [--binary-syntax] [--close-stderr]" - " [--exit-with-session] [--autolaunch=MACHINEID]" + " [--exit-with-session|--exit-with-x11] [--autolaunch=MACHINEID]" " [--config-file=FILENAME] [PROGRAM] [ARGS...]\n"); exit (ecode); } @@ -827,6 +827,7 @@ main (int argc, char **argv) const char *runprog = NULL; int remaining_args = 0; int exit_with_session; + int exit_with_x11 = FALSE; int binary_syntax = FALSE; int c_shell_syntax = FALSE; int bourne_shell_syntax = FALSE; @@ -870,6 +871,8 @@ main (int argc, char **argv) version (); else if (strcmp (arg, "--exit-with-session") == 0) exit_with_session = TRUE; + else if (strcmp (arg, "--exit-with-x11") == 0) + exit_with_x11 = TRUE; else if (strcmp (arg, "--close-stderr") == 0) close_stderr = TRUE; else if (strstr (arg, "--autolaunch=") == arg) @@ -981,6 +984,9 @@ main (int argc, char **argv) if (exit_with_session) verbose ("--exit-with-session enabled\n"); + if (exit_with_x11) + verbose ("--exit-with-x11 enabled\n"); + if (autolaunch) { #ifndef DBUS_BUILD_X11 @@ -1035,10 +1041,10 @@ main (int argc, char **argv) } verbose ("Autolaunch enabled (using X11).\n"); - if (!exit_with_session) + if (!exit_with_x11) { - verbose ("--exit-with-session automatically enabled\n"); - exit_with_session = TRUE; + verbose ("--exit-with-x11 automatically enabled\n"); + exit_with_x11 = TRUE; } if (!x11_init ()) @@ -1061,12 +1067,33 @@ main (int argc, char **argv) exit (0); } #endif /* DBUS_ENABLE_X11_AUTOLAUNCH */ +#endif /* DBUS_BUILD_X11 */ + } + else if (exit_with_x11) + { +#ifndef DBUS_BUILD_X11 + fprintf (stderr, "Session lifetime based on X11 requested, but X11 support not compiled in.\n"); + exit (1); +#else /* DBUS_BUILD_X11 */ + if (!read_machine_uuid_if_needed()) + { + fprintf (stderr, "Session lifetime based on X11 requested, but machine UUID unavailable.\n"); + exit (1); + } + + if (!x11_init ()) + { + fprintf (stderr, "Session lifetime based on X11 requested, but X11 initialization failed.\n"); + exit (1); + } +#endif /* DBUS_BUILD_X11 */ } +#ifdef DBUS_BUILD_X11 else if (read_machine_uuid_if_needed()) { x11_init(); -#endif /* DBUS_BUILD_X11 */ } +#endif /* DBUS_BUILD_X11 */ if (pipe (bus_pid_to_launcher_pipe) < 0 || @@ -1128,7 +1155,7 @@ main (int argc, char **argv) * and will also reap the pre-forked bus * daemon */ - babysit (exit_with_session, ret, + babysit (exit_with_session || exit_with_x11, ret, bus_pid_to_babysitter_pipe[READ_END]); exit (0); } |