[network-manager-applet/dcbw/die-die-die-dbus-glib-bgo760946: 3/3] editor: convert to GIO unix signal handling



commit 096da067acb73b4b4af90f70d27363b699482fbc
Author: Dan Williams <dcbw redhat com>
Date:   Thu Feb 18 14:36:36 2016 -0600

    editor: convert to GIO unix signal handling

 src/connection-editor/main.c |   29 +++++++++++------------------
 1 files changed, 11 insertions(+), 18 deletions(-)
---
diff --git a/src/connection-editor/main.c b/src/connection-editor/main.c
index 41c2e17..9314afc 100644
--- a/src/connection-editor/main.c
+++ b/src/connection-editor/main.c
@@ -31,6 +31,7 @@
 #include <glib/gi18n-lib.h>
 #include <glib.h>
 #include <glib-object.h>
+#include <glib-unix.h>
 
 #include "gsystem-local-alloc.h"
 #include "nm-connection-list.h"
@@ -267,25 +268,15 @@ try_existing_instance (GDBusConnection *bus,
        return TRUE;
 }
 
-static void
-signal_handler (int signo)
+static gboolean
+signal_handler (gpointer user_data)
 {
-       if (signo == SIGINT || signo == SIGTERM)
-               g_main_loop_quit (loop);
-}
+       int signo = GPOINTER_TO_INT (user_data);
 
-static void
-setup_signals (void)
-{
-       struct sigaction action;
-       sigset_t mask;
-
-       sigemptyset (&mask);
-       action.sa_handler = signal_handler;
-       action.sa_mask = mask;
-       action.sa_flags = 0;
-       sigaction (SIGTERM,  &action, NULL);
-       sigaction (SIGINT,  &action, NULL);
+       g_message ("Caught signal %d, shutting down...", signo);
+       g_main_loop_quit (loop);
+
+       return G_SOURCE_REMOVE;
 }
 
 int
@@ -358,7 +349,9 @@ main (int argc, char *argv[])
        if (handle_arguments (list, type, create, show, uuid, (create || show || uuid)))
                nm_connection_list_present (list);
 
-       setup_signals ();
+       g_unix_signal_add (SIGTERM, signal_handler, GINT_TO_POINTER (SIGTERM));
+       g_unix_signal_add (SIGINT, signal_handler, GINT_TO_POINTER (SIGINT));
+
        g_main_loop_run (loop);
        ret = 0;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]