tools: handle sigint in debug-gui
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 1 Nov 2018 03:56:16 +0000 (13:56 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 7 Nov 2018 05:03:52 +0000 (05:03 +0000)
Exit with success on SIGINT

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
tools/libinput-debug-gui.c

index 06ea0b8..62f0aec 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <gtk/gtk.h>
 #include <glib.h>
+#include <glib-unix.h>
 
 #include <libinput.h>
 #include <libinput-util.h>
@@ -918,6 +919,14 @@ usage(void) {
        printf("Usage: libinput debug-gui [options] [--udev <seat>|--device /dev/input/event0]\n");
 }
 
+static gboolean
+signal_handler(void *data)
+{
+       gtk_main_quit();
+
+       return FALSE;
+}
+
 int
 main(int argc, char **argv)
 {
@@ -930,6 +939,8 @@ main(int argc, char **argv)
 
        gtk_init(&argc, &argv);
 
+       g_unix_signal_add(SIGINT, signal_handler, NULL);
+
        tools_init_options(&options);
 
        while (1) {