NetworkManager r3264 - in trunk: . test
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3264 - in trunk: . test
- Date: Thu, 24 Jan 2008 03:00:35 +0000 (GMT)
Author: dcbw
Date: Thu Jan 24 03:00:35 2008
New Revision: 3264
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3264&view=rev
Log:
2008-01-23 Dan Williams <dcbw redhat com>
* test/libnm_glib_test.c
- (signal_handler, setup_signals): trap SIGINT and SIGTERM
- (main): set up signal handlers; call libnm_glib_shutdown
Modified:
trunk/ChangeLog
trunk/test/libnm_glib_test.c
Modified: trunk/test/libnm_glib_test.c
==============================================================================
--- trunk/test/libnm_glib_test.c (original)
+++ trunk/test/libnm_glib_test.c Thu Jan 24 03:00:35 2008
@@ -23,6 +23,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <signal.h>
+
#include "libnm_glib.h"
@@ -56,10 +58,33 @@
}
}
+static GMainLoop *loop = NULL;
+
+static void
+signal_handler (int signo)
+{
+ if (signo == SIGINT || signo == SIGTERM) {
+ g_message ("Caught signal %d, shutting down...", signo);
+ g_main_loop_quit (loop);
+ }
+}
+
+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);
+}
int main( int argc, char *argv[] )
{
- GMainLoop *loop;
libnm_glib_ctx *ctx;
guint id;
@@ -79,7 +104,10 @@
fprintf (stderr, "Registered Callback with ID %d\n", id);
loop = g_main_loop_new (NULL, FALSE);
+ setup_signals ();
g_main_loop_run (loop);
+ libnm_glib_shutdown (ctx);
+
exit (0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]