Index: main.cpp =================================================================== diff -u -r939d1bae9a394697d46ca913a2dc3442bf8ef82f -r805119c460b4a266d6401c8705f4427e7fbe270f --- main.cpp (.../main.cpp) (revision 939d1bae9a394697d46ca913a2dc3442bf8ef82f) +++ main.cpp (.../main.cpp) (revision 805119c460b4a266d6401c8705f4427e7fbe270f) @@ -39,6 +39,26 @@ #include "usbwatcher.h" #include "threads.h" +#include +/*! + * \brief signalhandler + * \details When application terminates it quits gracefully. + * \param sig - The Linux signal causes the termination. + */ +void signalhandler(int sig) +{ + if (sig == SIGINT) + { + qDebug() << QObject::tr("Application terminated by SIGINT"); + qApp->quit(); + } + else if (sig == SIGTERM) + { + qDebug() << QObject::tr("Application terminated by SIGTERM"); + qApp->quit(); + } +} + #ifdef UNIT_TEST #include TEST_CLASS_INCLUDE QTEST_MAIN(TEST_CLASS_NAME) @@ -50,6 +70,12 @@ */ int main(int argc, char *argv[]) { + +#ifndef SQUISH_COCO_BULD + signal(SIGINT , signalhandler); + signal(SIGTERM, signalhandler); +#endif + //! - Qt Application initialization and parameters settings // Qt Core Application parameters settings QApplication::setApplicationName(QLatin1String("Denali")); @@ -132,7 +158,7 @@ int app_exec = app.exec(); // Due to Qt Error the CAN Device cannot be disable/enable from withing another thread - // (other than main thread which is the owner of the CanDevice owner). + // (other than main thread which is the owner of the CanDevice). // So it needs to be done here in main thread. _CanInterface.quitDevice();