1
0
Fork 0
mirror of synced 2024-06-28 11:11:15 +12:00

Add a signal handler to launch helper

This commit is contained in:
lennard 2023-04-07 23:33:00 +02:00 committed by Dummerle
parent f1fa0ada1a
commit b48e1603cb

View file

@ -7,6 +7,7 @@ import time
import traceback
from argparse import Namespace
from logging import getLogger
from signal import signal, SIGINT, SIGTERM, strsignal
from typing import Union, Optional
from PyQt5.QtCore import QObject, QProcess, pyqtSignal, QUrl, QRunnable, QThreadPool, QSettings, Qt
@ -367,6 +368,15 @@ def start_game(args: Namespace):
app = RareLauncher(args)
app.setQuitOnLastWindowClosed(True)
# This prevents ghost QLocalSockets, which block the name, which makes it unable to start
# No handling for SIGKILL
def sighandler(s, frame):
logger.info(f"{strsignal(s)} received. Stopping")
app.stop()
app.exit(1)
signal(SIGINT, sighandler)
signal(SIGTERM, sighandler)
if not app.success:
return
app.start(args)