[gnome-keyring] daemon: Kill off foreground proceses when session dies
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring] daemon: Kill off foreground proceses when session dies
- Date: Fri, 16 Oct 2015 20:32:50 +0000 (UTC)
commit bf560bd195919d79a59a8642923ccac80c437bb1
Author: Ray Strode <rstrode redhat com>
Date: Thu Oct 15 16:07:22 2015 -0400
daemon: Kill off foreground proceses when session dies
Right now gnome-keyring will keep processes around forever
in some cases. They need to die when the session goes away,
at least.
Signed-off-by: Cosimo Cecchi <cosimoc gnome org>
* Don't leak a DBus connection
Signed-off-by: Stef Walter <stefw gnome org>
* Print error message if we cannot connect to bus
* Wait for gnome-keyring-daemon when --foreground
https://bugzilla.gnome.org/show_bug.cgi?id=756059
daemon/gkd-main.c | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gkd-main.c b/daemon/gkd-main.c
index af22cfc..28758ed 100644
--- a/daemon/gkd-main.c
+++ b/daemon/gkd-main.c
@@ -827,6 +827,14 @@ on_login_timeout (gpointer data)
return FALSE;
}
+static void
+on_vanished_quit_loop (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ g_main_loop_quit (user_data);
+}
+
int
main (int argc, char *argv[])
{
@@ -850,6 +858,9 @@ main (int argc, char *argv[])
* predictable startup.
*/
+ GDBusConnection *connection = NULL;
+ GError *error = NULL;
+
/*
* Before we do ANYTHING, we drop privileges so we don't become
* a security issue ourselves.
@@ -913,8 +924,20 @@ main (int argc, char *argv[])
*/
print_environment ();
close (parent_wakeup_fd);
- if (run_foreground)
- while (sleep(0x08000000) == 0);
+ if (run_foreground) {
+ connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+ if (error) {
+ g_warning ("Couldn't connect to session bus: %s", error->message);
+ g_clear_error (&error);
+ }
+ loop = g_main_loop_new (NULL, FALSE);
+ g_bus_watch_name (G_BUS_TYPE_SESSION, "org.gnome.keyring",
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ NULL, on_vanished_quit_loop, loop, NULL);
+ g_main_loop_run (loop);
+ g_clear_pointer (&loop, g_main_loop_unref);
+ g_clear_object (&connection);
+ }
cleanup_and_exit (0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]