Skip to content

High CPU when idle due to stdin EOF busy-loop after terminal is closed (/dev/pts/10) #11077

@hamza-u

Description

@hamza-u

What version of Codex CLI is running?

codex-cli 0.98.0

What subscription do you have?

Team Plan

Which model were you using?

gpt-5.2-codex

What platform is your computer?

Linux 6.8.0-79-generic x86_64 x86_64

What terminal emulator and version are you using (if applicable)?

Xterm.js (PTY-backed terminal on the server side, exposed over WebSocket)

What issue are you seeing?

Codex can spin at ~100% CPU while idle if its stdin points to a deleted TTY.
It repeatedly calls read(0, ..., 1024) and gets EOF (= 0) in a tight loop with no backoff/exit.

What steps can reproduce the bug?

Repro steps (

  1. Start Codex in terminal A.
  2. Cause terminal A/PTY to disappear (close terminal/session, detached invalid
    PTY, etc.).
  3. Leave Codex process running.
  4. Observe high CPU from one thread and repeated read(0)=0 via strace.

Impact

  • Sustained high CPU while “idle”
  • Wasted resources and battery
  • Misleading “Codex is busy” state

What is the expected behavior?

  • On persistent stdin EOF, Codex should either:
  1. Exit cleanly, or
  2. Sleep/backoff and avoid busy-spin CPU usage.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    TUIIssues related to the terminal user interface: text input, menus and dialogs, and terminal displaybugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions