summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorTomasz Sterna <tomek@xiaoka.com>2014-06-30 22:08:55 +0200
committerTomasz Sterna <tomek@xiaoka.com>2014-06-30 22:08:55 +0200
commita46ca25b3691caff077c225061e98b2da565422c (patch)
treeedace8e8daae0c735ff36cefd92fdde89070fb15 /daemon
parent7070ac0e01d774a5c56e19ac06e8d12fc0d78993 (diff)
Gracefully shutdown on SIGTERM and SIGINT
Diffstat (limited to 'daemon')
-rw-r--r--daemon/daemon.cpp17
1 files changed, 17 insertions, 0 deletions
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 <signal.h>
#include <QCoreApplication>
+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();
}