]> sigrok.org Git - pulseview.git/blobdiff - main.cpp
main: Add signal handler for SIGINT
[pulseview.git] / main.cpp
index f4506787364fa11ea01286cf2e569ffed5587c15..a7ab89fbf7422ada41d7050ac57715ce33f7f05d 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -20,6 +20,7 @@
 
 extern "C" {
 #include <sigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */
 
 extern "C" {
 #include <sigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */
+#include <signal.h>
 #include <stdint.h>
 #include <libsigrok/libsigrok.h>
 }
 #include <stdint.h>
 #include <libsigrok/libsigrok.h>
 }
@@ -45,11 +46,26 @@ void usage()
                "\n", PV_BIN_NAME, PV_DESCRIPTION);
 }
 
                "\n", PV_BIN_NAME, PV_DESCRIPTION);
 }
 
+/*
+ * SIGINT handler (likely recieved Ctrl-C from terminal)
+ */
+void sigint(int param)
+{
+       (void) param;
+       
+       qDebug("pv: Recieved SIGINT");
+       
+       /* TODO: Handle SIGINT */
+}
+
 int main(int argc, char *argv[])
 {
        int ret = 0;
        struct sr_context *sr_ctx = NULL;
 
 int main(int argc, char *argv[])
 {
        int ret = 0;
        struct sr_context *sr_ctx = NULL;
 
+       // Register a SIGINT handler
+       signal (SIGINT, sigint);
+
        QApplication a(argc, argv);
 
        // Set some application metadata
        QApplication a(argc, argv);
 
        // Set some application metadata