From cf7ce9ea0f1f475d01e28a1dd1d5229c43a8071d Mon Sep 17 00:00:00 2001 From: Martin Teichmann Date: Mon, 27 Oct 2025 10:55:46 +0100 Subject: [PATCH] reset signal handlers after they have fired in an non-interactive IOC, we wait for a SIGINT or SIGTERM to finish. For the asyncio dispatcher, this means we stop the asyncio event loop. It may, however, happen, that the asyncio event loop refuses to quit. In this case we can only SIGKILL the process, which is unnecessarily brutal. While not quitting the event loop althouggh we ask for it certainly is a bug, bugs like that do happen. This patch resets the signal handlers for SIGINT and SIGTERM to their default action after we have politely asked the event loop to quit, such that we can insist on quitting later. --- softioc/asyncio_dispatcher.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/softioc/asyncio_dispatcher.py b/softioc/asyncio_dispatcher.py index 78b84b2d..daf5888d 100644 --- a/softioc/asyncio_dispatcher.py +++ b/softioc/asyncio_dispatcher.py @@ -60,6 +60,9 @@ def signal_handler(signum, frame): stop_event.wait() + signal.signal(signal.SIGINT, signal.SIG_DFL) + signal.signal(signal.SIGTERM, signal.SIG_DFL) + async def __inloop(self, started): self.loop = asyncio.get_running_loop() self.__interrupt = asyncio.Event()