[BUG]

Resolved 💬 3 comments Opened Jan 24, 2026 by Eljonio Closed Jan 29, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

there is nothin to paste

What Should Happen?

● Title: Claude Code process continues running indefinitely after terminal/parent process closes, consuming high CPU and memory

---
Description:

When the terminal or parent process (e.g., VS Code) is closed, the Claude Code process does not terminate gracefully. Instead, it becomes orphaned (reparented
to PID 1/systemd) and continues running indefinitely in a CPU-bound loop, consuming significant system resources.

Environment:

  • OS: Ubuntu Linux 6.8.0-90-generic
  • Claude Code version: 2.1.19 (VS Code extension)
  • Shell: bash

Steps to reproduce:

  1. Start Claude Code in a terminal or via VS Code
  2. Close the terminal/VS Code window without explicitly exiting Claude (/exit or Ctrl+C)
  3. Check running processes with ps aux | grep claude

Expected behavior:
Claude Code should detect that stdin/stdout are closed or receive SIGHUP signal and terminate gracefully.

Actual behavior:
The process continues running as an orphan with the following characteristics:

$ ps aux | grep claude
malika 560427 133 17.2 34029304 1400256 ? Rl Jan23 1873:46 claude

$ ps -p 560427 -o pid,ppid,cmd
PID PPID CMD
560427 1 claude

Process diagnostics:

  • State: R (Running) - actively executing, not blocked
  • Parent PID: 1 (orphaned, adopted by systemd)
  • CPU usage: 133% (stuck in CPU-bound loop)
  • Memory: ~1.4-1.7 GB RSS
  • Threads: 11 active threads
  • Network sockets: 0 (no connections)
  • Kernel wait channel: 0 (not waiting on anything)
  • I/O: No read/write activity

The process accumulated 1873+ minutes of CPU time over ~24 hours while doing nothing useful.

Impact:

  • High CPU usage (133%) degrading system performance
  • Significant memory consumption (~1.7 GB per orphaned instance)
  • Multiple orphaned instances can accumulate over time if user frequently closes terminals

Suggested fix:

  • Handle SIGHUP signal to trigger graceful shutdown
  • Detect when stdin/stdout become invalid (closed/broken pipe) and exit
  • Implement a watchdog to detect loss of parent process or terminal

Workaround:
Manually kill the orphaned process:
kill <PID>

Error Messages/Logs

Steps to Reproduce

i alreadyexplain it in upper case

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.19 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

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