Exit gracefully on Ctrl-C and service stop
This commit is contained in:
parent
7bd7a94bd5
commit
542a5b7636
1 changed files with 6 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +45,11 @@ int main(int argc, char** argv)
|
||||||
QObject::connect(updater, SIGNAL(timeout()), battery, SLOT(updateData()));
|
QObject::connect(updater, SIGNAL(timeout()), battery, SLOT(updateData()));
|
||||||
updater->start(3000);
|
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();
|
int retval = app.exec();
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|
Loading…
Reference in a new issue