GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(cli): exit coder ssh --stdio when stdin closes before connection by Tyagiquamar · Pull Request #28597 · coder/coder

Conversation

@Tyagiquamar

@Tyagiquamar Tyagiquamar commented Aug 25, 2026

Copy link
Copy Markdown

Fixes #27954

Problem

On Windows, coder ssh --stdio proxy processes leak when the ProxyCommand client (e.g. Codex Desktop) abandons or retries a connection attempt. The CLI does not observe stdin closing until the SSH session is established, so abandoned processes keep waiting for the agent or sit in dial retries. One reporter accumulated 283 orphaned processes (~7 GB working set) that required taskkill /F to clear.

Root cause

In stdio mode nothing reads stdin before copier.copy starts. Every pre-connection stage (workspace resolution, agent wait, dial retries, the Coder Connect probe) ignores stdin, so a pipe closed by a dead or giving-up parent is never noticed. Unlike Linux, Windows has no SIGHUP-style parent-death signal to fall back on, which is why the accumulation shows up there.

Fix

Relay stdin through an io.Pipe starting at command setup. If the relay observes EOF or a read error before the SSH session begins consuming stdin, the command cancels itself and exits. After connection, the existing copy logic keeps owning stdin termination exactly as before; an atomic flag set in both connection paths gates the cancel so established-session semantics do not change.

Testing

New regression test fails on current main and passes with the fix:

$ go test ./cli/ -run 'TestSSHStdio_ExitWhenStdinClosedBeforeAgentConnects' -count=1

main (60b03138a):
    --- FAIL: TestSSHStdio_ExitWhenStdinClosedBeforeAgentConnects (17.09s)
        ssh_test.go:2498: coder ssh --stdio did not exit after stdin was closed

branch:
    --- PASS: TestSSHStdio_ExitWhenStdinClosedBeforeAgentConnects (2.57s)

Additional verification run locally on windows/amd64, Go 1.26.5:

$ go test ./cli/ -run 'TestSSH' -count=1 -timeout 2400s
ok      github.com/coder/coder/v2/cli   51.426s

$ gofmt -l cli/ssh.go cli/ssh_test.go        # no output
$ go vet ./cli/                              # exit 0

Broader cli-package failures seen on this machine (TestRoot, TestGitSSH, TestDERPHeaders, TestCommandHelp, TestServer, TestWorkspaceAgent) were confirmed to reproduce identically on pristine main; for example TestRoot shells out to cmd.exe /c printf, which does not exist on Windows. They are unrelated to this change.

AI involvement: developed with AI assistance under human direction; the commands and results above were produced by running them locally, per the AI contribution guidelines.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Tyagiquamar
fix(cli): exit coder ssh --stdio when stdin closes before connection
d499335
ProxyCommand clients close stdin when they abandon a connection
attempt. Nothing read stdin before the SSH session was established,
so on Windows (no parent-death signal) abandoned processes leaked
while waiting for the agent or dialing. Relay stdin through a pipe
and cancel the command when it terminates pre-connection; existing
copy logic still owns stdin termination once connected.

Closes coder#27954

Signed-off-by: Tyagiquamar <[email protected]>
@github-actions github-actions Bot assigned Tyagiquamar Aug 25, 2026
@Tyagiquamar
Tyagiquamar marked this pull request as ready for review August 31, 2026 06:36
@github-actions

github-actions Bot commented Aug 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tyagiquamar

Tyagiquamar commented Sep 1, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tyagiquamar

Tyagiquamar commented Sep 1, 2026

Copy link
Copy Markdown
Author

recheck

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

2 similar comments
@Tyagiquamar

Tyagiquamar commented Sep 1, 2026

Copy link
Copy Markdown
Author

recheck

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tyagiquamar

Tyagiquamar commented Sep 1, 2026

Copy link
Copy Markdown
Author

recheck

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tyagiquamar

Tyagiquamar commented Sep 6, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tyagiquamar

Tyagiquamar commented Sep 6, 2026

Copy link
Copy Markdown
Author

recheck

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tyagiquamar
chore: re-trigger CLA check
d1f21a8
@Tyagiquamar

Tyagiquamar commented Sep 9, 2026

Copy link
Copy Markdown
Author

Hi @DanielleMaywood, could you please review when you have a chance? Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale This issue is like stale bread. label Sep 19, 2026
@github-actions github-actions Bot closed this Sep 22, 2026
@sentientmonkey sentientmonkey mentioned this pull request Oct 27, 2026
bug: stale coder ssh --stdio / coder port-forward clients retry /coordinate → 404 forever after a workspace rebuild, causing sustained authenticated load on coderd/Postgres #31370
Open
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@Tyagiquamar Tyagiquamar

Labels

stale This issue is like stale bread.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

bug: Windows orphaned coder ssh --stdio processes after interrupted Codex connection retries

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Tyagiquamar
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.