diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2017-10-11 12:40:59 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2017-10-11 12:40:59 +0200 |
commit | 78d3415365239b412845671472e2b48f737d047a (patch) | |
tree | cf6ba45ce254894400e674d5f9389048eba3e5ac | |
parent | db1ab668e8ff1518db2c5f8834cbb65e1d667894 (diff) | |
download | uca-net-78d3415365239b412845671472e2b48f737d047a.tar.gz uca-net-78d3415365239b412845671472e2b48f737d047a.tar.bz2 uca-net-78d3415365239b412845671472e2b48f737d047a.tar.xz uca-net-78d3415365239b412845671472e2b48f737d047a.zip |
ucad: handle SIGINT gracefully
-rw-r--r-- | ucad.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -18,16 +18,17 @@ #include <glib-object.h> #include <gio/gio.h> #include <string.h> +#include <signal.h> #include <uca/uca-camera.h> #include <uca/uca-plugin-manager.h> #include "uca-net-protocol.h" #include "config.h" +static GMainLoop *loop; typedef void (*MessageHandler) (GSocketConnection *connection, UcaCamera *camera, gpointer message, GError **error); typedef void (*CameraFunc) (UcaCamera *camera, GError **error); - typedef struct { UcaNetMessageType type; MessageHandler handler; @@ -414,9 +415,14 @@ run_callback (GSocketService *service, GSocketConnection *connection, GObject *s } static void +sigint_handler (int unused) +{ + g_main_loop_quit (loop); +} + +static void serve (UcaCamera *camera, guint16 port, GError **error) { - GMainLoop *loop; GSocketService *service; service = g_threaded_socket_service_new (1); @@ -427,6 +433,7 @@ serve (UcaCamera *camera, guint16 port, GError **error) g_signal_connect (service, "run", G_CALLBACK (run_callback), camera); loop = g_main_loop_new (NULL, TRUE); + signal (SIGINT, sigint_handler); g_main_loop_run (loop); } |