From ca192a80b76700118b9bfd261a3d098b92ccfc31 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 21 May 2022 20:32:16 +0200 Subject: [PATCH] Fix suspending with process groups (#49) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since using raw mode via `raw.lflag &= ~(… | termios.ISIG)` pyrepl needs to handle SIGSTOP itself, but before this patch would only signal its own process. Using `0` for the pid signals the process group instead. Manual test: When running the following from a shell `Ctrl-z` will not give you the shell's prompt, but the process is stuck, and needs to be signaled to continue using `kill -CONT $pid`: > python -c 'import os; os.system("python pyrepl/reader.py")' I have noticed this when using pdbpp with pytest, which was wrapped in a shell script, not using `exec python …`. --- pyrepl/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrepl/commands.py b/pyrepl/commands.py index c121f34..62322f8 100644 --- a/pyrepl/commands.py +++ b/pyrepl/commands.py @@ -192,7 +192,7 @@ def do(self): r = self.reader p = r.pos r.console.finish() - os.kill(os.getpid(), signal.SIGSTOP) + os.kill(0, signal.SIGSTOP) ## this should probably be done ## in a handler for SIGCONT? r.console.prepare()