From 761fa5d49708e1d5ef4e8af6a7c923f23c72f209 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Sat, 12 Sep 2026 07:04:44 -0700 Subject: [PATCH] refactor(hooks): fold the interrupt-path comments into one WHY line The two inline comments on the BaseException branch restated what the code does; keep only the reason the branch exists (own process group means the terminal's SIGINT never reaches the hook). --- agent/shell_hooks.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/agent/shell_hooks.py b/agent/shell_hooks.py index 486efa9343..2bc8abc7a6 100644 --- a/agent/shell_hooks.py +++ b/agent/shell_hooks.py @@ -318,12 +318,11 @@ def _spawn(spec: ShellHookSpec, stdin_json: str) -> Dict[str, Any]: try: stdout, stderr = proc.communicate(input=stdin_json, timeout=spec.timeout) except BaseException as exc: - # BaseException, not Exception: Ctrl+C raises KeyboardInterrupt here, and the hook leads its own - # process group (above), so the terminal's SIGINT never reaches it — it would keep running. + # BaseException: the hook leads its own process group, so Ctrl+C's SIGINT never reaches it — only we can. kill_process_tree(proc) # the whole tree — forked helpers holding the pipes would stall the drain with suppress(Exception): proc.communicate(timeout=1) - if not isinstance(exc, Exception): # KeyboardInterrupt / SystemExit: reap the hook, then propagate + if not isinstance(exc, Exception): raise if not isinstance(exc, subprocess.TimeoutExpired): # pragma: no cover — defensive return failed(str(exc))