From 95571be27846112ae8a5503b3f03292f23bfef65 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 6 Oct 2023 18:30:59 +0000 Subject: [PATCH] fix: run deltachat-rpc-server in its own process group This ensures the server does not get SIGINT when the bot is running in a terminal and user presses ^C We want to send SIGTERM ourselves after clean shutdown, e.g. stopping I/O for all accounts. --- deltachat-rpc-client/src/deltachat_rpc_client/rpc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/rpc.py b/deltachat-rpc-client/src/deltachat_rpc_client/rpc.py index a0855c8e8..a59883e86 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/rpc.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/rpc.py @@ -39,6 +39,10 @@ class Rpc: "deltachat-rpc-server", stdin=subprocess.PIPE, stdout=subprocess.PIPE, + # Prevent subprocess from capturing SIGINT. + # We are not using `process_group` + # because it is not supported before Python 3.11. + preexec_fn=os.setpgrp, **self._kwargs, ) self.id = 0