diff --git a/service/src/harbour-batterybuddy-daemon.cpp b/service/src/harbour-batterybuddy-daemon.cpp index 6703d21..3a31a9f 100644 --- a/service/src/harbour-batterybuddy-daemon.cpp +++ b/service/src/harbour-batterybuddy-daemon.cpp @@ -4,6 +4,7 @@ #include "battery.h" #include "settings.h" #include +#include int main(int argc, char** argv) { @@ -44,6 +45,11 @@ int main(int argc, char** argv) QObject::connect(updater, SIGNAL(timeout()), battery, SLOT(updateData())); updater->start(3000); + // Exit gracefully on Ctrl-C and service stop + QObject::connect(&app, SIGNAL(aboutToQuit()), battery, SLOT(shutdown())); + signal(SIGINT, app.exit); + signal(SIGTERM, app.exit); + int retval = app.exec(); return retval;