Handle SIGINT, SIGTERM, SIGUP and SIGQUIT
This commit is contained in:
		@@ -14,9 +14,9 @@ class.
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
import asyncio
 | 
			
		||||
import atexit
 | 
			
		||||
import logging as log
 | 
			
		||||
import os
 | 
			
		||||
import pyotherside
 | 
			
		||||
import signal
 | 
			
		||||
import traceback
 | 
			
		||||
from concurrent.futures import Future
 | 
			
		||||
@@ -24,6 +24,8 @@ from operator import attrgetter
 | 
			
		||||
from threading import Thread
 | 
			
		||||
from typing import Coroutine, Sequence
 | 
			
		||||
 | 
			
		||||
import pyotherside
 | 
			
		||||
 | 
			
		||||
from .pyotherside_events import CoroutineDone, LoopException
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										16
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/main.cpp
									
									
									
									
									
								
							@@ -12,7 +12,7 @@
 | 
			
		||||
#include <QQuickStyle>
 | 
			
		||||
#include <QFontDatabase>
 | 
			
		||||
#include <QDateTime>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
#ifdef Q_OS_UNIX
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
@@ -77,6 +77,11 @@ void loggingHandler(
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void onExitSignal(int signum) {
 | 
			
		||||
    QApplication::exit(128 + signum);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int main(int argc, char *argv[]) {
 | 
			
		||||
    qInstallMessageHandler(loggingHandler);
 | 
			
		||||
 | 
			
		||||
@@ -88,6 +93,15 @@ int main(int argc, char *argv[]) {
 | 
			
		||||
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
 | 
			
		||||
    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
 | 
			
		||||
    // KDE from hijacking base controls and messing up everything
 | 
			
		||||
    QQuickStyle::setStyle("Fusion");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user