VS Code extension does not reap orphan child claude processes

Resolved 💬 3 comments Opened May 9, 2026 by ching0114 Closed May 12, 2026

Summary

The Claude Code VS Code extension spawns long-lived claude background processes that are not reaped when their associated tabs close, the extension reloads, or the user closes the editor without terminating individual sessions. These orphaned PIDs persist for hours, each holding 24–209 MB resident memory.

Reproduction

  1. Open VS Code with the Claude Code extension (build: anthropic.claude-code-2.1.128-darwin-arm64)
  2. Open a Claude tab; let it idle
  3. Close the tab (Cmd+W) OR start a new session via the command palette
  4. Run pgrep -af "claude" in a terminal

Observed: the original claude process from step 2 remains alive, parented to Code Helper (Plugin). New tabs spawn additional siblings under the same parent. After a typical day of use, 4–8 orphans accumulate.

Concrete observation (2026-05-08):

PID 18608 — alive 3h 21m, RSS 131 MB, exe ~/.vscode/extensions/anthropic.claude-code-*/native-binary/claude
PID 45137 — alive 9h 35m, RSS 85 MB
PID 50646 — alive 8h 55m, RSS 24 MB
PID 43431 — alive 11 min, RSS 209 MB  ← active tab, should remain

PIDs 18608/45137/50646 had no associated open tabs.

Impact

  • Memory pressure: combined RSS ~450 MB. On constrained machines this triggers aggressive macOS swap (swap at 17.88 GB observed, with cascading "Not Responding" states on other apps).
  • False-positive concurrent-session detection: project tooling that detects concurrent Claude sessions (for shared-worktree git index isolation) must add age-based and PPID-based filters to distinguish stale orphans from real sibling tabs. We ship a workaround script (cleanup_stale_claude_pids.sh) and complexity in detect_concurrent_sessions.py specifically because of this.

Workaround (project-side, not a fix)

We ship a dry-run-by-default script that identifies VS-Code-spawned claude processes ≥30 min old and offers to SIGTERM/SIGKILL them, protecting same-window siblings via PPID-based detection. This is tracked as a bandage with a 2026-08-08 review-by date; the real fix depends on upstream behavior.

Suggested upstream behaviors (any of these would resolve)

  1. Reap on tab close: when a Claude tab is closed via the editor UI, the extension SIGTERMs its associated child claude process within a short timeout.
  2. Reap on extension deactivation: orphans whose owning tab is gone die when the extension's deactivate() lifecycle method fires.
  3. Idle timeout: orphans without an active conversation for ≥30 min self-exit (the --idle-shutdown=N pattern from many CLI tools).
  4. Process-group cleanup at editor exit: ensure VS Code's Code Helper (Plugin) kills its claude children at exit.

Ask

Please confirm whether (a) this is a known issue with an existing tracker we should follow, or (b) this is the first report and a new tracker is being created. Either is fine; we just want to know when we can remove our workaround.

---
Reported from a project using Claude Code extensively for multi-session AI-assisted development. Platform: macOS 24.6.0 (darwin-arm64).

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗