summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ucad.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ucad.c b/ucad.c
index 35fb077..b97d9ac 100644
--- a/ucad.c
+++ b/ucad.c
@@ -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);
}