mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-23 00:02:38 -05:00
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.
20 lines
487 B
C++
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;
|
|
}
|
|
|