Windows: background Bash tool processes orphaned across sessions (block Git installer, leak resources)

Open 💬 0 comments Opened Jul 14, 2026 by 1Map

On Windows, long-running/background commands spawned by the Bash tool (tail -f, grep --line-buffered, backgrounded node servers, and hung scratchpad scripts) are not reaped when the session or VS Code window closes. Because Windows has no cascading process-tree kill, the children keep running indefinitely after their parent bash.exe/node dies.

Observed impact

After several sessions, 11 orphaned Git-Bash processes (bash.exe/tail.exe/grep.exe) + 7 orphaned node processes accumulated. The Git for Windows installer refused to proceed because these leftovers hold C:\Program Files\Git\usr\bin\{bash,tail,grep}.exe open. They also silently leak memory/ports (e.g. a leftover node serve.js still bound to a dev port).

All orphans were traceable to Claude Code via the wrapper: source /c/Users/<user>/.claude/shell-snapshots/snapshot-bash-*.sh && eval '...'. Their parent PIDs were all dead.

Repro

  1. Run a background/streaming Bash command (e.g. tail -f logs, or a backgrounded dev server).
  2. End the session or close VS Code.
  3. Inspect processes — the shell-snapshots-wrapped bash.exe and its node/tail/grep children persist indefinitely.

Suggested fix

Track PIDs of spawned background processes per session and terminate the full tree on session teardown. On Windows, assigning spawned processes to a Job Object with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE gives cascading termination that plain parent-death does not.

Environment

  • OS: Windows 11 Pro (10.0.26200)
  • Claude Code: VS Code extension
  • Shell: Git for Windows bash via the Bash tool

View original on GitHub ↗