From a46ca25b3691caff077c225061e98b2da565422c Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Mon, 30 Jun 2014 22:08:55 +0200 Subject: Gracefully shutdown on SIGTERM and SIGINT --- daemon/daemon.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'daemon/daemon.cpp') diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index 30341d8..ab61171 100644 --- a/daemon/daemon.cpp +++ b/daemon/daemon.cpp @@ -28,8 +28,21 @@ #include "manager.h" +#include #include +void signalhandler(int sig) +{ + if (sig == SIGINT) { + qDebug() << "quit by SIGINT"; + qApp->quit(); + } + else if (sig == SIGTERM) { + qDebug() << "quit by SIGTERM"; + qApp->quit(); + } +} + int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); @@ -40,5 +53,9 @@ int main(int argc, char *argv[]) Manager manager(&watch, &dbus, &voice); + signal(SIGINT, signalhandler); + signal(SIGTERM, signalhandler); + QObject::connect(&app, SIGNAL(aboutToQuit()), &watch, SLOT(endPhoneCall())); + return app.exec(); } -- cgit v1.2.3