Handle SIGINT, SIGTERM, SIGUP and SIGQUIT
This commit is contained in:
parent
aff5f45ca0
commit
f316a24550
|
@ -14,9 +14,9 @@ class.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import atexit
|
||||||
import logging as log
|
import logging as log
|
||||||
import os
|
import os
|
||||||
import pyotherside
|
|
||||||
import signal
|
import signal
|
||||||
import traceback
|
import traceback
|
||||||
from concurrent.futures import Future
|
from concurrent.futures import Future
|
||||||
|
@ -24,6 +24,8 @@ from operator import attrgetter
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from typing import Coroutine, Sequence
|
from typing import Coroutine, Sequence
|
||||||
|
|
||||||
|
import pyotherside
|
||||||
|
|
||||||
from .pyotherside_events import CoroutineDone, LoopException
|
from .pyotherside_events import CoroutineDone, LoopException
|
||||||
|
|
||||||
|
|
||||||
|
|
16
src/main.cpp
16
src/main.cpp
|
@ -12,7 +12,7 @@
|
||||||
#include <QQuickStyle>
|
#include <QQuickStyle>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <signal.h>
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -77,6 +77,11 @@ void loggingHandler(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void onExitSignal(int signum) {
|
||||||
|
QApplication::exit(128 + signum);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
qInstallMessageHandler(loggingHandler);
|
qInstallMessageHandler(loggingHandler);
|
||||||
|
|
||||||
|
@ -88,6 +93,15 @@ int main(int argc, char *argv[]) {
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
// Register handlers for quit signals, e.g. SIGINT/Ctrl-C in unix terminals
|
||||||
|
signal(SIGINT, onExitSignal);
|
||||||
|
signal(SIGTERM, onExitSignal);
|
||||||
|
#ifdef Q_OS_UNIX
|
||||||
|
signal(SIGQUIT, onExitSignal);
|
||||||
|
signal(SIGHUP, onExitSignal);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Force the default universal QML style, notably prevents
|
// Force the default universal QML style, notably prevents
|
||||||
// KDE from hijacking base controls and messing up everything
|
// KDE from hijacking base controls and messing up everything
|
||||||
QQuickStyle::setStyle("Fusion");
|
QQuickStyle::setStyle("Fusion");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user