From: Alexandru Gagniuc Date: Wed, 2 Jan 2013 17:37:49 +0000 (-0600) Subject: main: Add signal handler for SIGINT X-Git-Tag: pulseview-0.1.0~131 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=31e6731d976cb2b398c92763a9d3507437b8a826;p=pulseview.git main: Add signal handler for SIGINT Add a SIGINT handler as requested here: http://www.airwebreathe.org.uk/projects/index.php?title=PulseView#Make_PulseView_respond_properly_to_SIGINT Signed-off-by: Alexandru Gagniuc --- diff --git a/main.cpp b/main.cpp index f4506787..a7ab89fb 100644 --- a/main.cpp +++ b/main.cpp @@ -20,6 +20,7 @@ extern "C" { #include /* First, so we avoid a _POSIX_C_SOURCE warning. */ +#include #include #include } @@ -45,11 +46,26 @@ void usage() "\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; + // Register a SIGINT handler + signal (SIGINT, sigint); + QApplication a(argc, argv); // Set some application metadata