diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ff5979..820905c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.7.1] - 2025-06-05 + +### Fixed + +- Correcly handle UNIX signals in the user instance of the agent + ## [5.7.0] - 2025-05-27 ### Changed diff --git a/linux/debian/changelog b/linux/debian/changelog index 8bf0185..2e07f9b 100644 --- a/linux/debian/changelog +++ b/linux/debian/changelog @@ -1,3 +1,9 @@ +ogagent (5.7.1-1) stable; urgency=medium + + * Correctly handle UNIX signals + + -- OpenGnsys developers Thu, 05 Jun 2025 12:07:30 +0200 + ogagent (5.7.0-1) stable; urgency=medium * Use TLS again diff --git a/src/OGAgentUser.py b/src/OGAgentUser.py index a390a35..f25029c 100755 --- a/src/OGAgentUser.py +++ b/src/OGAgentUser.py @@ -35,6 +35,8 @@ import json import sys import time import os +import socket +import signal from PyQt6 import QtCore, QtGui, QtWidgets from about_dialog_ui import Ui_OGAAboutDialog @@ -328,6 +330,29 @@ if __name__ == '__main__': trayIcon.quit() sys.exit(1) + ## begin SIGTERM handling + signal_socket = socket.socketpair() + signal_socket[0].setblocking(False) + signal_socket[1].setblocking(False) + signal.set_wakeup_fd(signal_socket[0].fileno()) + + def signal_handler(signum, frame): + #print (f"Received signal {signum}") + pass + + def qt_signal_handler(): + data = signal_socket[1].recv(1) + #print(f"Signal ({data}) received via socket, shutting down gracefully...") + if trayIcon: + trayIcon.quit() + + signal.signal(signal.SIGTERM, signal_handler) + signal.signal(signal.SIGINT, signal_handler) + + notifier = QtCore.QSocketNotifier(signal_socket[1].fileno(), QtCore.QSocketNotifier.Type.Read) + notifier.activated.connect(qt_signal_handler) + ## end SIGTERM handling + app.aboutToQuit.connect(trayIcon.cleanup) trayIcon.show() diff --git a/src/VERSION b/src/VERSION index 42cdd0b..64ff7de 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1 @@ -5.7.0 +5.7.1