summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2014-03-06 10:33:21 +0100
committerStef Walter <stefw@gnome.org>2014-03-06 16:46:20 +0100
commit0e3cf35b6d5b899897367d6db637b3294dd5bf7d (patch)
tree311b16f0e3a1f67b819a904be1260b6a0ba6dd86 /daemon
parentc7fc0421ece00e684f5932a6285c122a917bf610 (diff)
downloadgnome-keyring-0e3cf35b6d5b899897367d6db637b3294dd5bf7d.tar.gz
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.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gkd-main.c13
1 files changed, 13 insertions, 0 deletions
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 */
}