[gnome-session/gnome-3-8] Set up systemd journal redirection after early option processing



commit 71840e759c9dcaedc7a45069c1b565ad2bfb69da
Author: Colin Walters <walters verbum org>
Date:   Fri Jul 5 17:14:49 2013 -0400

    Set up systemd journal redirection after early option processing
    
    And don't do it if --debug is passed.  This makes --help work, and
    avoiding it with --debug should help gnome-settings-daemon's test
    suite.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=703661

 gnome-session/main.c |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/gnome-session/main.c b/gnome-session/main.c
index 8f7cb4b..dc6db5f 100644
--- a/gnome-session/main.c
+++ b/gnome-session/main.c
@@ -296,18 +296,6 @@ main (int argc, char **argv)
                 gsm_util_init_error (TRUE, "%s", error->message);
         }
 
-#ifdef HAVE_SYSTEMD
-        {
-                int journalfd;
-
-                journalfd = sd_journal_stream_fd (PACKAGE, LOG_INFO, 0);
-                if (journalfd >= 0) {
-                        dup2(journalfd, 1);
-                        dup2(journalfd, 2);
-                }
-        }
-#endif
-
         /* Check GL, if it doesn't work out then force software fallback */
         if (!check_gl (&error)) {
                 gl_failed = TRUE;
@@ -346,6 +334,22 @@ main (int argc, char **argv)
                 exit (0);
         }
 
+        /* Rebind stdout/stderr to the journal explicitly, so that
+         * journald picks ups the nicer "gnome-session" as the program
+         * name instead of whatever shell script GDM happened to use.
+         */
+#ifdef HAVE_SYSTEMD
+        if (!debug) {
+                int journalfd;
+
+                journalfd = sd_journal_stream_fd (PACKAGE, LOG_INFO, 0);
+                if (journalfd >= 0) {
+                        dup2(journalfd, 1);
+                        dup2(journalfd, 2);
+                }
+        }
+#endif
+
         if (gl_failed) {
                 gsm_fail_whale_dialog_we_failed (FALSE, TRUE, NULL);
                 gtk_main ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]