summaryrefslogtreecommitdiff
path: root/stc/stcd.c
diff options
context:
space:
mode:
Diffstat (limited to 'stc/stcd.c')
-rw-r--r--stc/stcd.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/stc/stcd.c b/stc/stcd.c
index d7b26be..28ad6a6 100644
--- a/stc/stcd.c
+++ b/stc/stcd.c
@@ -25,6 +25,7 @@
#include <syslog.h>
#include "stc.h"
+#include "gposixsignal.h"
/* ---------------------------------------------------------------------------------------------------- */
@@ -827,11 +828,21 @@ on_item_changed (StcMonitor *monitor,
/* ---------------------------------------------------------------------------------------------------- */
+static gboolean
+on_sigint (gpointer user_data)
+{
+ GMainLoop *loop = user_data;
+ g_print ("Handling SIGINT\n");
+ g_main_loop_quit (loop);
+ return FALSE;
+}
+
int
main (int argc, char *argv[])
{
GMainLoop *loop;
_StcDaemon *daemon;
+ guint sigint_id;
g_type_init ();
@@ -843,8 +854,18 @@ main (int argc, char *argv[])
loop = g_main_loop_new (NULL, FALSE);
daemon = _stc_daemon_new ();
+ sigint_id = _g_posix_signal_watch_add (SIGINT,
+ G_PRIORITY_DEFAULT,
+ on_sigint,
+ loop,
+ NULL);
+
g_main_loop_run (loop);
+ g_print ("Shutting down\n");
+
+ if (sigint_id > 0)
+ g_source_remove (sigint_id);
g_object_unref (daemon);
g_main_loop_unref (loop);