X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tools%2Fdbus-launch.c;h=86d325f938ebceaca5938c50061ac7e273d5623c;hb=973684f02290cfda7552cc0d1a87c5767660550f;hp=7b1bb37b559f278ef5edcfc029ef45471fb3a604;hpb=ab0cebd8830f6d48e49083a06de17a6a9e5d4d98;p=platform%2Fupstream%2Fdbus.git diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 7b1bb37..86d325f 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -105,6 +105,7 @@ save_machine_uuid (const char *uuid_arg) machine_uuid = xstrdup (uuid_arg); } +#ifdef DBUS_BUILD_X11 #define UUID_MAXLEN 40 /* Read the machine uuid from file if needed. Returns TRUE if machine_uuid is * set after this function */ @@ -146,7 +147,7 @@ out: fclose(f); return ret; } - +#endif /* DBUS_BUILD_X11 */ void verbose (const char *format, @@ -492,11 +493,20 @@ kill_bus_when_session_ends (void) else tty_fd = -1; - if (tty_fd >= 0) - verbose ("stdin isatty(), monitoring it\n"); + if (x_fd >= 0) + { + verbose ("session lifetime is defined by X, not monitoring stdin\n"); + tty_fd = -1; + } + else if (tty_fd >= 0) + { + verbose ("stdin isatty(), monitoring it\n"); + } else - verbose ("stdin was not a TTY, not monitoring it\n"); - + { + verbose ("stdin was not a TTY, not monitoring it\n"); + } + 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"); @@ -624,6 +634,7 @@ babysit (int exit_with_session, s = getenv ("DBUS_DEBUG_OUTPUT"); if (s == NULL || *s == '\0') dup2 (dev_null_fd, 2); + close (dev_null_fd); } else { @@ -745,31 +756,31 @@ pass_info (const char *runprog, const char *bus_address, pid_t bus_pid, if (envvar == NULL || args == NULL) goto oom; - args[0] = xstrdup (runprog); + args[0] = xstrdup (runprog); if (!args[0]) goto oom; - for (i = 1; i <= (argc-remaining_args); i++) - { - size_t len = strlen (argv[remaining_args+i-1])+1; - args[i] = malloc (len); - if (!args[i]) - goto oom; - strncpy (args[i], argv[remaining_args+i-1], len); - } - args[i] = NULL; + for (i = 1; i <= (argc-remaining_args); i++) + { + size_t len = strlen (argv[remaining_args+i-1])+1; + args[i] = malloc (len); + if (!args[i]) + goto oom; + strncpy (args[i], argv[remaining_args+i-1], len); + } + args[i] = NULL; - strcpy (envvar, "DBUS_SESSION_BUS_ADDRESS="); - strcat (envvar, bus_address); - putenv (envvar); + strcpy (envvar, "DBUS_SESSION_BUS_ADDRESS="); + strcat (envvar, bus_address); + putenv (envvar); - execvp (runprog, args); - fprintf (stderr, "Couldn't exec %s: %s\n", runprog, strerror (errno)); - exit (1); + execvp (runprog, args); + fprintf (stderr, "Couldn't exec %s: %s\n", runprog, strerror (errno)); + exit (1); } else { print_variables (bus_address, bus_pid, bus_wid, c_shell_syntax, - bourne_shell_syntax, binary_syntax); + bourne_shell_syntax, binary_syntax); } verbose ("dbus-launch exiting\n"); @@ -1152,7 +1163,6 @@ main (int argc, char **argv) char *end; long wid = 0; long val; - int ret2; verbose ("=== Parent dbus-launch continues\n"); @@ -1226,6 +1236,8 @@ main (int argc, char **argv) #ifdef DBUS_ENABLE_X11_AUTOLAUNCH if (xdisplay != NULL) { + int ret2; + verbose("Saving x11 address\n"); ret2 = x11_save_address (bus_address, bus_pid, &wid); /* Only get an existing dbus session when autolaunching */