diff options
Diffstat (limited to 'tests/test-proxy.c')
-rw-r--r-- | tests/test-proxy.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/tests/test-proxy.c b/tests/test-proxy.c index 77530e7..bbf44d6 100644 --- a/tests/test-proxy.c +++ b/tests/test-proxy.c @@ -28,12 +28,31 @@ GMainLoop *main_loop; +#ifndef G_OS_WIN32 +#include <glib-unix.h> +#endif + +static gboolean +unix_signal_handler (gpointer user_data) +{ + g_main_loop_quit (main_loop); + + return G_SOURCE_REMOVE; +} + +#ifdef G_OS_WIN32 +/* + * Since in Windows this is basically called from + * the ConsoleCtrlHandler which does not share the restrictions of Unix signals + */ static void interrupt_signal_handler (G_GNUC_UNUSED int signum) { - g_main_loop_quit (main_loop); + unix_signal_handler (NULL); } +#endif + static void subscription_lost_cb (G_GNUC_UNUSED GUPnPServiceProxy *proxy, const GError *reason, @@ -166,9 +185,6 @@ main (G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) GError *error; GUPnPContext *context; GUPnPControlPoint *cp; -#ifndef G_OS_WIN32 - struct sigaction sig_action; -#endif /* G_OS_WIN32 */ setlocale (LC_ALL, ""); @@ -201,11 +217,9 @@ main (G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) /* Hook the handler for SIGTERM */ #ifndef G_OS_WIN32 - memset (&sig_action, 0, sizeof (sig_action)); - sig_action.sa_handler = interrupt_signal_handler; - sigaction (SIGINT, &sig_action, NULL); + g_unix_signal_add (SIGINT, unix_signal_handler, NULL); #else - signal(SIGINT,interrupt_signal_handler); + signal(SIGINT, interrupt_signal_handler); #endif /* G_OS_WIN32 */ g_main_loop_run (main_loop); |