mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-21 17:21:18 -08:00
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]>