Bug: /exit command leaves orphan child processes (memory leak)
Resolved 💬 2 comments Opened Jan 20, 2026 by edgelines Closed Jan 20, 2026
Description
The /exit command does not properly terminate child processes, causing them to become orphan processes that accumulate over time and consume significant memory.
Environment
- OS: macOS Darwin 25.2.0
- Claude Code Version: Latest (installed via
~/.local/bin/claude) - Shell: zsh/bash
Steps to Reproduce
- Start Claude Code session:
claude - Use the session normally
- Exit with
/exitcommand - Repeat steps 1-3 multiple times over several days
- Check processes:
ps aux | grep claude | wc -l
Expected Behavior
All Claude-related processes should terminate when /exit is called.
Actual Behavior
- Only the main process terminates
- Child processes become orphans (PPID becomes 1)
- Processes accumulate over days
Evidence from my system:
# After several days of normal usage with /exit:
$ ps aux | grep claude | wc -l
150+
# Memory consumption:
~10GB total from accumulated orphan processes (60-170MB each)
# Orphan process detection:
$ ps -o pid,ppid,command | grep claude
PID PPID COMMAND
34946 1 /Users/.../.local/bin/claude # PPID=1 means orphaned
Impact
- Memory leak: Each orphan process consumes 60-170MB
- System slowdown: 150+ processes accumulated over ~5 days
- User confusion: Users believe
/exitproperly terminates the session
Workaround
# Kill all Claude processes manually
pkill -f claude
# Then start a new session
claude
Suggested Fix
The /exit command should:
- Send termination signals to all child processes in the process group
- Wait for child processes to terminate before exiting
- Or use
kill -- -$$to kill the entire process group
Additional Context
Process tree shows child processes spawned by Claude Code are not receiving termination signals:
Main Claude Process (terminated by /exit)
├── Child Process 1 (orphaned, PPID→1)
├── Child Process 2 (orphaned, PPID→1)
└── Child Process N (orphaned, PPID→1)This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗