Description
When a parent Claude Code terminal session is terminated (e.g., VS Code integrated terminal closed/killed), subagents spawned via the Task tool are not properly cleaned up. The orphaned subagent process accumulates massive memory (30GB in this case) and must be manually killed.
Steps to Reproduce
- Run Claude Code in VS Code integrated terminal
- Spawn a subagent using the Task tool (in this case,
n8n-workflow subagent to monitor an ongoing execution)
- Parent session freezes or becomes unresponsive
- Terminate the VS Code terminal
- Subagent process is orphaned (reparented to launchd/PID 1 on macOS)
Observed Behavior
- Subagent process continues running detached
- Process accumulates ~30GB memory in WebKit Malloc (mostly swapped to disk)
- Process state shows as uninterruptible wait (
U)
- Regular
kill doesn't work; requires kill -9
- Briefly becomes zombie before cleanup
Memory Profile (from vmmap -summary)
Physical footprint: 30.8G
Physical footprint (peak): 30.8G
WebKit Malloc 37.0G virtual 708.9M resident 29.8G swapped
Expected Behavior
- Subagent processes should be terminated when parent session exits
- If orphaned, processes should not leak memory indefinitely
- Graceful signal handling (SIGTERM should work)
Environment
- Claude Code version: 2.1.17
- Platform: macOS 26.2 (Darwin 25.2.0, ARM64)
- Terminal: VS Code integrated terminal
- Subagent type:
n8n-workflow
Additional Context
Process details before kill:
PID PPID RSS VSZ COMMAND
73002 1 479984 538806112 claude
Parent PID 1 (launchd) confirms orphaned state.
Description
When a parent Claude Code terminal session is terminated (e.g., VS Code integrated terminal closed/killed), subagents spawned via the Task tool are not properly cleaned up. The orphaned subagent process accumulates massive memory (30GB in this case) and must be manually killed.
Steps to Reproduce
n8n-workflowsubagent to monitor an ongoing execution)Observed Behavior
U)killdoesn't work; requireskill -9Memory Profile (from
vmmap -summary)Expected Behavior
Environment
n8n-workflowAdditional Context
Process details before kill:
Parent PID 1 (launchd) confirms orphaned state.