[dconf] Graceful exit on signal
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf] Graceful exit on signal
- Date: Sun, 11 Sep 2011 18:46:58 +0000 (UTC)
commit 3ecf9aab99ff201ba66e7d7f6e79accbd6797660
Author: Ryan Lortie <desrt desrt ca>
Date: Sun Sep 11 14:46:10 2011 -0400
Graceful exit on signal
Exit gracefully on receipt of SIGTERM, SIGHUP or SIGINT.
Require glib 2.29.90 for the API used to do this.
configure.ac | 2 +-
service/service.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8d31d13..5661b5c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@ GLIB_GSETTINGS
GTK_DOC_CHECK([1.15])
# Dependencies
-PKG_CHECK_MODULES(glib, glib-2.0 >= 2.27.3)
+PKG_CHECK_MODULES(glib, glib-2.0 >= 2.29.90)
PKG_CHECK_MODULES(gio, gio-2.0)
PKG_CHECK_MODULES(dbus, dbus-1)
diff --git a/service/service.c b/service/service.c
index 5e54604..b2ab1cf 100644
--- a/service/service.c
+++ b/service/service.c
@@ -19,6 +19,7 @@
* Author: Ryan Lortie <desrt desrt ca>
*/
+#include <glib-unix.h>
#include <gio/gio.h>
#include <string.h>
#include <stdlib.h>
@@ -419,6 +420,16 @@ name_lost (GDBusConnection *connection,
exit (1);
}
+static gboolean
+exit_service (gpointer data)
+{
+ DConfState *state = data;
+
+ g_main_loop_quit (state->main_loop);
+
+ return TRUE;
+}
+
int
main (void)
{
@@ -426,6 +437,7 @@ main (void)
GBusType type;
g_type_init ();
+
dconf_state_init (&state);
if (state.is_session)
@@ -433,6 +445,10 @@ main (void)
else
type = G_BUS_TYPE_SYSTEM;
+ g_unix_signal_add (SIGTERM, exit_service, &state);
+ g_unix_signal_add (SIGINT, exit_service, &state);
+ g_unix_signal_add (SIGHUP, exit_service, &state);
+
g_bus_own_name (type, "ca.desrt.dconf", G_BUS_NAME_OWNER_FLAGS_NONE,
bus_acquired, name_acquired, name_lost, &state, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]