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 "config.h"
+// Global pointer to our QApplication
+QApplication *g_app = NULL;
void usage()
{
fprintf(stderr,
"\n", PV_BIN_NAME, PV_DESCRIPTION);
}
+/*
+ * SIGINT handler (likely recieved Ctrl-C from terminal)
+ */
+void sigint(int param)
+{
+ (void) param;
+
+ qDebug("pv: Recieved SIGINT");
+
+ if (g_app)
+ g_app->quit();
+}
+
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);
+ // Now we have an application to populate our global pointer
+ g_app = &a;
// Set some application metadata
QApplication::setApplicationVersion(PV_VERSION_STRING);