Skip to content

tailcat: don't hang an exec connection after the command exits - #189

Merged
bradfitz merged 1 commit into
mainfrom
bradfitz/exec-stdin-hang
Nov 18, 2026
Merged

bradfitz merged 1 commit into
mainfrom
bradfitz/exec-stdin-hang

Conversation

@bradfitz

Copy link
Copy Markdown
Member

runConnCommand waited for both copy goroutines before calling
cmd.Wait. The comment claimed the stdin copy would finish on its own
once the process was gone, but that only holds if the client sends
more data. A client that stays connected without sending anything or
half-closing left the stdin copy blocked in c.Read forever, so
cmd.Wait never ran, leaking a zombie process, two goroutines and the
connection.

Now copy stdout in the calling goroutine, wait for the command to
exit, and then close the connection to unblock the stdin copy. Stdin
is still forwarded concurrently, so interactive commands keep working.

Thanks to @CJstate for pointing out the problem in PR #182!

runConnCommand waited for both copy goroutines before calling
cmd.Wait. The comment claimed the stdin copy would finish on its own
once the process was gone, but that only holds if the client sends
more data. A client that stays connected without sending anything or
half-closing left the stdin copy blocked in c.Read forever, so
cmd.Wait never ran, leaking a zombie process, two goroutines and the
connection.

Now copy stdout in the calling goroutine, wait for the command to
exit, and then close the connection to unblock the stdin copy. Stdin
is still forwarded concurrently, so interactive commands keep working.

Thanks to @CJstate for pointing out the problem in PR #182!

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
@bradfitz
bradfitz merged commit 171b9d1 into main Nov 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant