mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 21:00:16 +01:00
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 git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3264 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
54b327f35a
commit
fe7259194b
2 changed files with 35 additions and 1 deletions
|
|
@ -1,3 +1,9 @@
|
|||
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
|
||||
|
||||
2008-01-21 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* include/NetworkManager.h
|
||||
|
|
|
|||
|
|
@ -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 void status_printer (libnm_glib_ctx *ctx, gpointer user_data)
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ int main( int argc, char *argv[] )
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue