summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2016-02-18 14:36:36 -0600
committerDan Williams <dcbw@redhat.com>2016-02-19 11:27:39 -0600
commit096da067acb73b4b4af90f70d27363b699482fbc (patch)
tree6c3dad0648eb6702f9dc4308aa961e393a5188f6
parent9b002809514ae905b2ad9590a794c4a2503b89e7 (diff)
downloadnetwork-manager-applet-dcbw/die-die-die-dbus-glib-bgo760946.tar.gz
editor: convert to GIO unix signal handlingdcbw/die-die-die-dbus-glib-bgo760946
-rw-r--r--src/connection-editor/main.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/connection-editor/main.c b/src/connection-editor/main.c
index 41c2e177..9314afc6 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;