Added signal handler to properly exit application and switch off the leds.

This commit is contained in:
T. van der Zwan 2013-08-22 20:06:13 +00:00
parent e2eb5ecd7f
commit 9033927685
1 changed files with 16 additions and 0 deletions

View File

@ -1,4 +1,7 @@
// C++ includes
#include <csignal>
// QT includes
#include <QCoreApplication>
@ -14,12 +17,20 @@
// JsonServer includes
#include <jsonserver/JsonServer.h>
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();
}