From 0e3cf35b6d5b899897367d6db637b3294dd5bf7d Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Thu, 6 Mar 2014 10:33:21 +0100 Subject: daemon: When in foreground mode, close stdout when done initializing This indicates to the caller both that it's the end of the environment variables, and also provides a synchronization point where tests can wait for the daemon. --- daemon/gkd-main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/daemon/gkd-main.c b/daemon/gkd-main.c index 57d3288e..731d205f 100644 --- a/daemon/gkd-main.c +++ b/daemon/gkd-main.c @@ -567,6 +567,7 @@ print_environment (pid_t pid) printf ("%s\n", *env); if (pid) printf ("GNOME_KEYRING_PID=%d\n", (gint)pid); + fflush (stdout); } static gboolean @@ -883,6 +884,18 @@ static gboolean on_idle_initialize (gpointer data) { gkr_daemon_initialize_steps (run_components); + + /* + * Close stdout and so that the caller knows that we're + * all initialized, (when run in foreground mode). + * + * However since some logging goes to stdout, redirect that + * to stderr. We don't want the caller confusing that with + * valid output anyway. + */ + if (dup2 (2, 1) < 1) + g_warning ("couldn't redirect stdout to stderr"); + return FALSE; /* don't run again */ } -- cgit v1.2.3