1 Commits

Author SHA1 Message Date
Mike Bannister b2969deeee fix: isolate interactive PATH probes from caller terminal (#2074)
* fix: restore terminal pgrp after PATH lookup

Snapshot the terminal foreground process group before the shell PATH
probe in ShellCommandLocator.runShellCommand and restore it on return,
so `watch` sessions keep TTY foreground ownership and Ctrl+C keeps
working after CLI commands.

Block SIGTTOU on the calling thread across the restoring tcsetpgrp: the
restore runs from a background process group (the probe shell moves the
terminal foreground and the post-completion kill(-pgid) cleanup strands
it), where the default SIGTTOU action would otherwise stop the CLI.

* fix: harden terminal foreground restoration

* fix: preserve newer terminal foreground jobs

* fix: restore redirected terminal ownership

* fix: harden terminal foreground recovery

* fix: recover dead terminal descendant groups

* fix: reject unrelated terminal foreground groups

* fix: isolate interactive PATH probes

* fix: define detached spawn flag on Linux

* fix: support detached probes on Linux

* test: gate detached session proof to Linux

* fix: restore terminal pgrp after PATH lookup

Snapshot the terminal foreground process group before the shell PATH
probe in ShellCommandLocator.runShellCommand and restore it on return,
so `watch` sessions keep TTY foreground ownership and Ctrl+C keeps
working after CLI commands.

Block SIGTTOU on the calling thread across the restoring tcsetpgrp: the
restore runs from a background process group (the probe shell moves the
terminal foreground and the post-completion kill(-pgid) cleanup strands
it), where the default SIGTTOU action would otherwise stop the CLI.

* fix: harden terminal foreground restoration

* fix: preserve newer terminal foreground jobs

* fix: restore redirected terminal ownership

* fix: harden terminal foreground recovery

* fix: recover dead terminal descendant groups

* fix: reject unrelated terminal foreground groups

* fix: isolate interactive PATH probes

* fix: support detached probes on Linux

* test: gate detached session proof to Linux

* fix: define detached spawn flag on Linux

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-11 18:28:26 -07:00