[FEATURE] Include pid/pgid in terminal_info ACP metadata for orphan process detection

Resolved 💬 1 comment Opened Apr 27, 2026 by Dnreikronos Closed May 31, 2026

What variant of Codex are you using?

CLI

What feature would you like to see?

Add pid and pgid fields to the terminal_info metadata sent via ACP ToolCall._meta. Currently terminal_info only includes terminal_id and cwd. With pid/pgid, ACP clients like Zed can detect and clean up orphaned child processes after the shell exits.

Current:

{"terminal_info": {"terminal_id": "toolu_...", "cwd": "/some/path"}}

Proposed:

{"terminal_info": {"terminal_id": "toolu_...", "cwd": "/some/path", "pid": 12345, "pgid": 12345}}

_meta is freeform JSON, so no ACP protocol changes are needed — just two extra fields in existing JSON.

Use case:

  1. User starts agent session in Zed (or any ACP client)
  2. Codex CLI runs something that forks background workers (dev server, build watcher, etc.)
  3. Shell exits with 0, CLI sends terminal_exit
  4. Child processes keep running, consuming resources, no parent
  5. ACP client can't touch them because it has no PID or PGID
  6. With pid/pgid in terminal_info, client calls killpg(pgid, 0) after exit, finds orphans, cleans up with SIGTERM

Alternatives considered:

  • A reverse terminal/kill in ACP protocol (client-to-agent direction) — works but requires protocol-level change on both sides for what could be two JSON fields
  • Scanning /proc by command string — too fragile, too many false positives

Additional information

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗