Removing a session from history doesn't terminate its process — orphaned `claude` processes accumulate (esp. Remote-SSH)
Environment
- Claude Code VS Code extension v2.1.162 (linux-arm64)
- VS Code Remote-SSH (extension host + sessions run on the remote Linux server; client on another machine)
- Conversation hosted as a docked view (sidebar/panel), not editor tabs
Summary
There is no user-facing command to end/terminate a session, and removing a session from the history list (trash icon) deletes only the session record — it never signals the underlying claude process. Under Remote-SSH the processes run server-side and survive client disconnects, so they accumulate indefinitely until the host reboots or they're killed by hand.
Evidence
A session is three decoupled artifacts:
- the
claudenative-binary process, - a registry file
~/.claude/sessions/<pid>.json(pid → sessionId → cwd), - a transcript
~/.claude/projects/<proj>/<sessionId>.jsonl(persists by design).
Findings on one host:
- The extension contributes 22 commands; none of them stop / end / exit / kill / close a session's process. Closest are New Conversation and Reopen Closed Session.
- 10 live
claudeprocesses were running (~3 GB combined RSS). The registry mapped 1:1 to live PIDs, and 5 of them had been idle ~14 h with zero transcript writes — clearly orphaned. (40 transcripts on disk vs. 10 live sessions.) - The process is the only thing holding the resources:
kill -TERM <pid>exits each one cleanly, and on graceful exit the process self-removes its~/.claude/sessions/<pid>.json. So the registry is process-lifecycle-managed — the UI simply never sends the terminate signal. Killing the 5 stale PIDs dropped RAM held by sessions from ~3.0 GB to ~1.6 GB.
Impact
A memory/CPU leak that is invisible in the UI. Worst under Remote-SSH, where session children run on the server and outlive client disconnects (laptop sleep, tunnel drop, window close); on a shared host they compete with other workloads.
Repro
- Open the extension over Remote-SSH as a docked view.
- Start several conversations (or reload the window so sessions are restored).
- Remove old ones via the history trash icon, and/or disconnect the client.
- On the server:
ps aux | grep native-binary/claude→ the old processes are still running;~/.claude/sessions/still holds their<pid>.json.
Expected
Ending a session (or removing it from history while it's still live) terminates its process — or there is a visible "End session" action, or history-trash prompts to terminate a still-running session.
Actual
Nothing in the UI terminates the process; it persists until reboot or a manual kill.
Suggested fixes (any one)
- Add an "End session" command + button that SIGTERMs the child.
- Make history-trash terminate the process when it's still live (or prompt).
- Make the remote server's idle-shutdown actually reap detached session children.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗