Nyall Dawson 620db06324 Add external qt-unix-signals library
This library, original taken from https://github.com/sijk/qt-unix-signals
(but a maintained fork exists at https://github.com/nyalldawson/qt-unix-signals),
handles unix signal watching using the Qt libraries.

It allows for detection of signals like SIGINT and SIGTERM,
and allows Qt applications to respond gracefully to these.

Included in external libraries for use in QGIS terminal
applications.
2019-03-05 18:43:02 +10:00

20 lines
487 B
C++

#include <QCoreApplication>
#include <QDebug>
#include "sigwatch.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
qDebug() << "Hello from process" << QCoreApplication::applicationPid();
UnixSignalWatcher sigwatch;
sigwatch.watchForSignal(SIGINT);
sigwatch.watchForSignal(SIGTERM);
QObject::connect(&sigwatch, SIGNAL(unixSignal(int)), &app, SLOT(quit()));
int exitcode = app.exec();
qDebug() << "Goodbye";
return exitcode;
}