Handle unix signals

This commit is contained in:
Kevin Yue
2020-02-15 23:37:30 +08:00
parent 7fa8357a1c
commit 704554d3a5
6 changed files with 264 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
#include <QtDBus>
#include "gpservice.h"
#include "singleapplication.h"
#include "sigwatch.h"
int main(int argc, char *argv[])
{
@@ -12,7 +13,14 @@ int main(int argc, char *argv[])
return 1;
}
new GPService;
GPService service;
UnixSignalWatcher sigwatch;
sigwatch.watchForSignal(SIGINT);
sigwatch.watchForSignal(SIGTERM);
sigwatch.watchForSignal(SIGQUIT);
sigwatch.watchForSignal(SIGHUP);
QObject::connect(&sigwatch, SIGNAL(unixSignal(int)), &service, SLOT(quit()));
return app.exec();
}