From 9033927685d97b3ceeb741a4fad51924a87d2ca3 Mon Sep 17 00:00:00 2001 From: "T. van der Zwan" Date: Thu, 22 Aug 2013 20:06:13 +0000 Subject: [PATCH] Added signal handler to properly exit application and switch off the leds. --- src/hyperiond/hyperiond.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index 25e57875..3c9688ed 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -1,4 +1,7 @@ +// C++ includes +#include + // QT includes #include @@ -14,12 +17,20 @@ // JsonServer includes #include +void signal_handler(const int signum) +{ + QCoreApplication::quit(); +} + int main(int argc, char** argv) { // Initialising QCoreApplication QCoreApplication app(argc, argv); std::cout << "QCoreApplication initialised" << std::endl; + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); + if (argc < 2) { std::cout << "Missing required configuration file. Usage:" << std::endl; @@ -42,4 +53,9 @@ int main(int argc, char** argv) app.exec(); std::cout << "Application closed" << std::endl; + + // Stop the frame grabber + dispmanx.stop(); + // Clear all colors (switchting off all leds) + hyperion.clearall(); }