Repository navigation
Description
Title
pty: opencode-pty daemon leaks zombie shell children (never reaped)
Body
Summary
The opencode-pty daemon that executes shell-tool commands never reaps its
finished children, so every shell command leaves a zombie process. The daemon
is long-lived and shared across sessions, so the zombies accumulate without
bound (~150 observed after ~3 days of normal use).
Environment
- opencode version: v2.3.0
- OS: Ubuntu 24.04, Linux 7.0.0-42-generic x86_64
- Terminal: VS Code (TERM_PROGRAM=vscode, TERM=xterm-256color, COLORTERM=truecolor)
- Shell: /bin/bash
- Install/channel: latest
- Active plugins: none found in config
Reproduction
- Start an opencode session and run a few shell-tool commands (
ls,
git status, a pipeline likemake ... | tail, etc.). - After each command finishes, run:
ps -eo stat,ppid,pid,cmd | awk '$1 ~ /^Z/' - Every finished command is still listed as
<defunct>with the
opencode-pty daemonPID as parent, and stays there.
Expected Behavior
Finished shell commands are reaped by the pty daemon; no zombie processes
accumulate over time.
Actual Behavior
Zombies accumulate indefinitely. After ~3 days of use with a shared daemon:
$ ps -eo stat,ppid,pid,cmd | awk '$1 ~ /^Z/ {print $4}' | sort | uniq -c | sort -rn
101 [bash]
26 [sed]
14 [git]
5 [tail]
1 [make]
1 [grep]
All of them share the same parent:
PID PPID ELAPSED CMD
380876 ... 2-22:25:28 ~/.cache/opencode/bin/opencode-pty/0.5.2-bc9cb0fa0ebb4e56/opencode-pty \
daemon --runtime-dir ~/.local/state/opencode/pty --name <uuid>
The oldest zombies date back to ~2d20h, i.e. since that daemon started.
Not just the pipeline leader is affected: sed/tail/grep pipeline
children also end up parented to the daemon and are never reaped either.
Additional Context
- Sending
kill -CHLD <daemon pid>does not trigger reaping. - Restarting the daemon clears the zombies (they are reparented to init and
reaped), but that is disruptive to active sessions' terminals. - Impact so far is only PID-slot usage, but the growth is unbounded and
proportional to executed shell commands, so long-lived installs will hit it. - Reproducible consistently: each shell command reliably adds one or more
zombies.
Activity
opencodejr commentedon Nov 16, 2026
Thanks for the detailed report. I think this is a duplicate of #63817, which reports this leak and has been reproduced on 2.3.0.
Possible duplicates and related issues, ordered by likelihood:
<defunct>under theopencode-pty daemon(0.5.2) on 2.3.0, and the count grows over the daemon's lifetime. The reproduction there found that exited commands are only reaped once they drop out of the newest 25 per directory, so directories that go idle keep their zombies until the server restarts.I'm closing this issue now as a duplicate of #63817. Please add your details there; your zombie breakdown across pipeline children (
sed,tail,grep) and the note thatkill -CHLDdoesn't trigger reaping would be useful. If you think this is a different problem, reply here and the issue will reopen.