codex - 💡(How to fix) Fix Codex CLI leaves stale no-TTY process consuming high CPU after session exit [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#21021Fetched 2026-05-05 05:54:20
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×4commented ×1

Codex CLI appears to leave a stale native codex process running after a previous TUI session has exited/disconnected. The stale process had no TTY and consumed significant CPU for hours, while a newer active Codex session from the same working directory was running normally.

Error Message

A previous Codex process pair remained alive long after the session appeared to be gone:

Root Cause

I am not attaching full logs publicly because they may contain session/workspace data, but I can provide specific sanitized excerpts if useful.

Code Example

PID      PPID     SID      TTY  STAT  %CPU  ELAPSED   STARTED
2364433  2363561  2363561  ?    Sl     0.0  03:52:15  Mon May  4 20:29:18 2026
2364440  2364433  2363561  ?    Sl    63.8  03:52:15  Mon May  4 20:29:18 2026

---

2364433 node .../bin/codex --no-alt-screen
2364440 .../node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex/codex --no-alt-screen

---

PID      PPID     SID      TTY    STAT  %CPU  ELAPSED  STARTED
2465381  2464666  2464666  pts/3  Sl+    0.0  09:41    Tue May  5 00:11:52 2026
2465388  2465381  2464666  pts/3  Sl+    0.3  09:41    Tue May  5 00:11:52 2026

---

2026-05-04 20:32  ~/.codex/sessions/2026/05/04/rollout-2026-05-04T20-29-18-019df2f6-e0be-77c2-97f4-a24c11628ecf.jsonl

---

50M   ~/.codex/log/codex-tui.log
929M  ~/.codex/logs_2.sqlite
4.3M  ~/.codex/logs_2.sqlite-wal
4.4M  ~/.codex/state_5.sqlite
2.5M  ~/.codex/state_5.sqlite-wal
RAW_BUFFERClick to expand / collapse

Summary

Codex CLI appears to leave a stale native codex process running after a previous TUI session has exited/disconnected. The stale process had no TTY and consumed significant CPU for hours, while a newer active Codex session from the same working directory was running normally.

Environment

  • Codex CLI: codex-cli 0.128.0
  • npm package: @openai/[email protected]
  • Node.js: v24.14.0
  • Platform: Linux x64
  • Invocation mode: interactive TUI with --no-alt-screen
  • Working directory: same repo/worktree for both the stale and current sessions

Observed behavior

A previous Codex process pair remained alive long after the session appeared to be gone:

PID      PPID     SID      TTY  STAT  %CPU  ELAPSED   STARTED
2364433  2363561  2363561  ?    Sl     0.0  03:52:15  Mon May  4 20:29:18 2026
2364440  2364433  2363561  ?    Sl    63.8  03:52:15  Mon May  4 20:29:18 2026

Commands:

2364433 node .../bin/codex --no-alt-screen
2364440 .../node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex/codex --no-alt-screen

At the same time, the current active Codex session looked normal and was attached to a TTY:

PID      PPID     SID      TTY    STAT  %CPU  ELAPSED  STARTED
2465381  2464666  2464666  pts/3  Sl+    0.0  09:41    Tue May  5 00:11:52 2026
2465388  2465381  2464666  pts/3  Sl+    0.3  09:41    Tue May  5 00:11:52 2026

Both process pairs had the same cwd. The old process pair had no TTY and the native child was burning ~64% CPU. Killing the old pair immediately removed the high CPU usage, leaving only the current session.

Additional local state

The rollout file corresponding to the old session was modified shortly after startup:

2026-05-04 20:32  ~/.codex/sessions/2026/05/04/rollout-2026-05-04T20-29-18-019df2f6-e0be-77c2-97f4-a24c11628ecf.jsonl

So the session data appears to have stopped updating around 20:32 local time, while the process continued running until it was manually killed around 00:23 local time.

The local Codex state/log files are fairly large, which may or may not be related:

50M   ~/.codex/log/codex-tui.log
929M  ~/.codex/logs_2.sqlite
4.3M  ~/.codex/logs_2.sqlite-wal
4.4M  ~/.codex/state_5.sqlite
2.5M  ~/.codex/state_5.sqlite-wal

Expected behavior

When a TUI session exits, disconnects, or otherwise becomes detached, Codex should terminate its native child process or leave it idle without high CPU usage.

Actual behavior

A detached/no-TTY native codex child process remained alive for hours and consumed high CPU until manually killed.

Notes

I am not attaching full logs publicly because they may contain session/workspace data, but I can provide specific sanitized excerpts if useful.

extent analysis

TL;DR

Killing the stale Codex process pair immediately removes the high CPU usage, suggesting a potential issue with the process termination or idle handling.

Guidance

  • Investigate the rollout file modification timestamp to determine if the session data update cessation is related to the process becoming stale.
  • Review the local Codex state and log files for any errors or warnings that may indicate why the native child process remains active.
  • Consider adding logging or monitoring to track the process lifecycle and identify potential issues with termination or idle handling.
  • Verify if the issue persists with a clean Codex installation or a different working directory to isolate the problem.

Example

No code snippet is provided as the issue seems to be related to process management and termination rather than a specific code error.

Notes

The large size of the local Codex state and log files may be unrelated to the issue, but it's worth investigating if they contain any relevant information. The fact that killing the stale process pair resolves the high CPU usage suggests a potential issue with process termination or idle handling.

Recommendation

Apply a workaround by implementing a script to periodically check for and kill stale Codex process pairs, as the root cause of the issue is not immediately clear. This will help mitigate the high CPU usage until a more permanent fix can be found.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When a TUI session exits, disconnects, or otherwise becomes detached, Codex should terminate its native child process or leave it idle without high CPU usage.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING