[gnome-keyring] daemon: When in foreground mode, close stdout when done initializing
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring] daemon: When in foreground mode, close stdout when done initializing
- Date: Thu, 6 Mar 2014 17:47:26 +0000 (UTC)
commit 0e3cf35b6d5b899897367d6db637b3294dd5bf7d
Author: Stef Walter <stefw gnome org>
Date: Thu Mar 6 10:33:21 2014 +0100
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 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gkd-main.c b/daemon/gkd-main.c
index 57d3288..731d205 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 */
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]