From 8941f6996127d4189e6f4052d4be7b3111b0926c Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Thu, 6 Aug 2026 08:27:18 -0400 Subject: [PATCH] start_new_session when creating SSH tunnels According to * https://docs.python.org/3/library/subprocess.html#popen-constructor > If start_new_session is true the setsid() system call will be made in the child process prior to the execution of the subprocess. The hope is that setsid() keeps the tunnel process from receiving ctrl-c interrupts from the REPL. --- changelog.md | 5 +++++ mycli/ssh_tunnel.py | 1 + 2 files changed, 6 insertions(+) diff --git a/changelog.md b/changelog.md index daf79f20..b05af289 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,11 @@ Features * Always clean favorite queries on save and fetch. +Bugfixes +--------- +* Call `setsid()` to keep SSH tunnels from receiving Ctrl-C interrupts. + + Documentation --------- * Document double-return requirement after `/fs` in multi-line mode. diff --git a/mycli/ssh_tunnel.py b/mycli/ssh_tunnel.py index d22a8475..12a742cc 100644 --- a/mycli/ssh_tunnel.py +++ b/mycli/ssh_tunnel.py @@ -187,6 +187,7 @@ def _run(self) -> None: stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, + start_new_session=True, ) except OSError as exc: self._startup_error = exc