[FEATURE] Include pid/pgid in terminal_info ACP metadata for orphan process detection
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Agent terminals in Zed are display-only. When Claude Code runs a terminal command, Zed gets the output streamed through ACP ToolCall._meta (terminal_info, terminal_output, terminal_exit), but there's no actual process handle on Zed's side.
The problem: if a command spawns child processes that outlive the shell, Zed can't detect or kill them. Right now terminal_info only has terminal_id and cwd.
Without pid/pgid, there's no way to call killpg() after the shell exits.
I dug into this on the Zed side and confirmed there's nothing we can do without process group info from Claude Code.
Related Zed issue: https://github.com/zed-industries/zed/issues/51455
Proposed Solution
Add pid and pgid to the terminal_info metadata Claude Code already sends. Claude Code knows the shell's PID when it spawns it, so this is two extra fields in
existing JSON.
Current:
{"terminal_info": {"terminal_id": "toolu_...", "cwd": "/some/path"}}
With this change:
{"terminal_info": {"terminal_id": "toolu_...", "cwd": "/some/path", "pid": 12345, "pgid": 12345}}
_meta is freeform JSON, so no ACP protocol changes are needed.
Alternative Solutions
- A reverse terminal/kill in the ACP protocol (client-to-agent direction). Works, but that's a protocol-level change on both sides for what could be two JSON
fields.
- Scanning /proc by command string. Too fragile, too many false positives.
Priority
Critical - Blocking my work
Feature Category
CLI commands and flags
Use Case Example
- User starts an agent session in Zed
- Claude Code runs something that forks background workers (build script with watchers, dev server, etc.)
- Shell exits with 0, Claude Code sends terminal_exit
- Child processes keep running, consuming resources, no parent
- Zed can't touch them because it has no PID or PGID
- With pid/pgid in terminal_info, Zed calls killpg(pgid, 0) after exit, finds the orphans, and cleans up with SIGTERM
Additional Context
I traced through the Zed code that handles this. The parsing lives at crates/agent_servers/src/acp.rs where terminal_info is already extracted from _meta. Once Claude Code starts sending pid/pgid, the Zed side is a small patch.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗