Background Bash tasks leave orphaned child processes on kill

Resolved 💬 3 comments Opened Feb 20, 2026 by arealhobo Closed Feb 24, 2026

Description

When a background Bash task (started with run_in_background) is stopped via TaskStop, only the parent shell process is terminated. Child processes spawned by the command (e.g., via concurrently, npm run dev, etc.) continue running as orphans.

Steps to Reproduce

  1. Start a dev server as a background task:

``
Bash: cd /path/to/project && npm run dev
(run_in_background: true)
`
Where
npm run dev uses concurrently` to spawn multiple child processes (e.g., tsx watch + vite)

  1. Stop the task via TaskStop with the task ID
  1. Check for orphaned processes:

``
netstat -ano | grep -E ':3001 |:5174 ' | grep LISTENING
``

Expected Behavior

All child processes (grandchildren of the shell) should be terminated when the background task is stopped.

Actual Behavior

Only the parent shell is killed. Child processes (tsx, vite, node, etc.) remain running and hold onto their ports. Users must manually find and kill them via taskkill /F /PID <pid>.

Environment

  • OS: Windows Server 2025 (Git Bash shell)
  • Claude Code version: Latest (as of Feb 2026)
  • Shell: bash

Notes

  • This is particularly problematic with tools like concurrently, npm-run-all, or any command that spawns multiple child processes
  • On Windows, process groups / job objects may be needed to ensure all descendants are terminated
  • On Unix, sending SIGTERM to the process group (kill -TERM -<pgid>) would handle this

View original on GitHub ↗

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