Files
tailscale/ssh/tailssh
Kristoffer Dalby 7f8afb526c ssh/tailssh: signal the session's process group, not just the child
Teardown signalled cmd.Process.Pid, which is the incubator. The user's
shell is a grandchild and never saw it, so any HUP-trapping cleanup the
user installed was silently skipped.

New terminateSession helper signals the negated PID so the kernel
delivers to every process in the group; ESRCH maps to nil, meaning the
session already exited. plan9 has no Unix process groups and falls back
to Process.Signal.

Both command paths now lead their own group. newIncubatorCommand sets
Setpgid, and so does the direct-exec path (no tailscaledPath: embedders
and tests), which previously left the shell in tailscaled's group where
kill(-pid) found no such pgid and the ESRCH looked like a clean exit.
The PTY path gets this via Setsid in startWithPTY.

TestSessionTerminationKillsProcess spawns a grandchild over the
direct-exec path and fails without the Setpgid.

This is not sufficient on its own when su is in play: su -c starts the
command in a new session, so the group signal still cannot reach it.
The next commit handles that; TestIntegrationSIGHUP, which covers the
incubator path, passes only once both are in.

Updates #18256

Signed-off-by: Kristoffer Dalby <[email protected]>
2026-07-27 13:18:07 +00:00
..
2026-04-10 10:48:50 -07:00