Orphaned background shells from prior sessions persist and re-trigger commands in new sessions

Resolved 💬 6 comments Opened Apr 19, 2026 by danblake Closed Jun 20, 2026

Environment

  • Claude Code: 2.1.114 (CLI) / desktop app running session via binary 2.1.111
  • macOS: 26.5 (build 25F5053d)
  • Hardware: Apple Silicon

What happened

While working in a LinkMan project session, xcodebuild -scheme LinkMan test kept launching on its own and respawning LinkMan.app — without me asking.

Investigation showed the culprit is the Claude Code desktop app process itself (PID 3197, running .../claude-code/2.1.111/claude.app/.../claude). It still had child /bin/zsh -c wrappers alive from an EntArch project session that started ~1 hour before the LinkMan session began:

4493  3197  zsh -c ... eval 'ASPNETCORE_ENVIRONMENT=Development ... dotnet run
              --project .../EntArch.WebApi.csproj --urls=http://localhost:3100 ...'
4555  3197  zsh -c ... eval 'cd src/Web && pnpm --filter @entarch/platform-admin dev ...'
4582  3197  zsh -c ... eval 'cd src/Web && pnpm --filter @entarch/tenant-admin dev ...'

Each wrapper sources ~/.claude/shell-snapshots/snapshot-zsh-*.sh — the signature of a Claude-launched background command. They survived the end of the EntArch session and kept running inside a completely unrelated LinkMan session. Separately, a background xcodebuild ... scheme LinkMan test chain (PIDs 29380→29382) kept respawning LinkMan.app after kill until I killed the parent zsh wrapper, not just the child.

Expected

Background shells spawned by a session should be reaped when that session ends — or at minimum not remain attached to the desktop app across sessions and unrelated project contexts.

Actual

They persist under the desktop app's PID, continue running dev servers / test loops, and produce unexplained CPU usage and process churn in the next session the user opens.

Repro (approximate)

  1. Start a Claude Code session in project A; let it spawn background dev servers via run_in_background: true.
  2. End that session without explicitly killing the background shells.
  3. Open a new Claude Code session in project B.
  4. ps -eo pid,ppid,command | grep snapshot-zsh — project A's shells are still alive, parented to the desktop app.

Workaround

pgrep -fl snapshot-zsh at session start and kill any stale wrappers.

View original on GitHub ↗

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