Gracefully handle signals in retroshare-android-service

This commit is contained in:
Gioacchino Mazzurco 2018-01-25 15:50:12 +01:00
parent 8c21bfcd54
commit ac9a8437fa

View File

@ -20,6 +20,7 @@
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QTimer> #include <QTimer>
#include <csignal>
#ifdef __ANDROID__ #ifdef __ANDROID__
# include "util/androiddebug.h" # include "util/androiddebug.h"
@ -38,6 +39,13 @@ int main(int argc, char *argv[])
#endif #endif
QCoreApplication app(argc, argv); QCoreApplication app(argc, argv);
signal(SIGINT, &QCoreApplication::exit);
signal(SIGTERM, &QCoreApplication::exit);
#ifdef SIGBREAK
signal(SIGBREAK, &QCoreApplication::exit);
#endif // def SIGBREAK
ApiServer api; ApiServer api;
RsControlModule ctrl_mod(argc, argv, api.getStateTokenServer(), &api, true); RsControlModule ctrl_mod(argc, argv, api.getStateTokenServer(), &api, true);
api.addResourceHandler( api.addResourceHandler(