GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pty: opencode-pty daemon does not reap exited shells, leaving one zombie per tool call · Issue #65572 · anomalyco/opencode

pty: opencode-pty daemon does not reap exited shells, leaving one zombie per tool call #65572

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
pty: opencode-pty daemon does not reap exited shells, leaving one zombie per tool call#65572
Copy link
Labels
area/serviceBackground service and serverplatform/macosmacOStype/bugSomething is brokenversion/v2OpenCode 2.x

Description

@faria-jr
faria-jr
opened on Nov 22, 2026
Issue body actions

Summary

The opencode-pty helper daemon does not reap its exited shell children. Every completed tool/shell call leaves one <defunct> process whose PPID is the daemon. On a long-lived desktop session this accumulates indefinitely and can exhaust the PID table.

This is distinct from #53564 (zombies reparented to opencode serve as PID 1 in a container): here the zombie's parent is the still-running opencode-pty daemon, so the child is never reparented to PID 1 and no init can reap it.

Environment

  • opencode: v2.3.0 (opencode), package @opencode/cli 2.3.2
  • pty helper: opencode-pty 0.5.2-ed3adb8c7531fef5
  • OS: macOS 27.0.1 (darwin), arm64
  • Install: nvm global npm package
  • Mode: desktop/CLI session (opencode serve --stdio)

Reproduction

  1. Start a normal OpenCode session on macOS.
  2. Run any shell tool call (for example ps aux) and let it finish.
  3. Observe a new zombie whose PPID is that session's opencode-pty daemon.

Observed

Two daemons, both about 10 minutes old, already had 37 zombies between them:

$ ps ax -o pid=,ppid=,stat=,command= | awk '$3 ~ /^Z/'
92555 92554 Z <defunct>
92556 92554 Z <defunct>
92557 92554 Z <defunct>
92567 92566 Z <defunct>
93840 92566 Z <defunct>
...

Counts by parent:

24 92566
13 92554

Parent command:

opencode-pty daemon --runtime-dir ~/.local/state/opencode/pty --name <uuid>

Across a longer run, three daemons accumulated 54 zombies; on a fresh daemon the rate was roughly 12 zombies per minute during active tool use. One zombie appeared for each completed shell command, including the ps invocation used to inspect them.

Expected

The daemon should reap exited children (a SIGCHLD handler or a waitpid(-1, ..., WNOHANG) loop) so no <defunct> processes accumulate.

Impact

  • Unbounded PID-table growth on long-lived sessions (hundreds of zombies over days).
  • Misleading process listings and monitoring.
  • Zombies themselves are cheap, but the leak is only cleared by restarting the daemon/session.

Workarounds

  • Restart the OpenCode session/daemon periodically to clear the zombies.
  • Kill the opencode-pty daemon; it is recreated on demand.

Related

  • server: PID 1 does not reap orphaned grandchildren, leaving zombies and shells stuck "running" #53564: PID 1 in a container does not reap reparented grandchildren (different parent).
  • shell: every tool call stalls ~5s while the PTY daemon fails to reconnect (ECONNREFUSED /tmp/opencode-pty-<uid>/*.sock) #64080: PTY daemon reconnect stalls (same component, different symptom).
  • serve: /api/pty leaks orphan bash processes when connect-token is denied #50699: /api/pty leaks orphan bash processes when connect-token is denied.

Captured with ps on macOS 27.0.1, opencode v2.3.0.

Activity

  1. opencodejr commented on Nov 22, 2026

    @opencodejr
    opencodejrBot
    on Nov 22, 2026
    Contributor
    More actions

    Thanks for the detailed report. I think this is a duplicate of #63817: the same zombie-per-shell-command leak under opencode-pty daemon, introduced with 2.3.0 and pty 0.5.2. It was fixed by #64251, which moves OpenCode to @opencode/pty 0.6.0. That daemon reaps commands when they exit.

    Possible duplicates and related issues, ordered by likelihood:

    • pty: shell commands leave zombies under opencode-pty daemon on Linux (2.3.0) #63817: the same leak on 2.3.0 / pty 0.5.2, reproduced there and closed as fixed by fix(core): pin @opencode/pty 0.6.0 and use protocol 9 #64251
    • opencode-pty daemon leaks zombie child processes (unbounded growth under single daemon PID) #63976: the same unbounded zombie growth under one daemon PID, also fixed by fix(core): pin @opencode/pty 0.6.0 and use protocol 9 #64251
    • process-daemon: pipe children stay as zombies (steady-state 25 Z) until eviction; safe to reap once the process group is empty #64076: the same zombies, explained by the per-directory cap of exited commands
    • server: PID 1 does not reap orphaned grandchildren, leaving zombies and shells stuck "running" #53564: related but different, zombies reparented to PID 1 in a container

    Your output says opencode is v2.3.0 and the daemon is opencode-pty 0.5.2-…, even though the installed package is 2.3.2. So the process you inspected is probably still the old one: either a server or session started before the upgrade, or another opencode earlier on your PATH. Could you check which -a opencode and opencode --version, then fully restart OpenCode (including any opencode serve / desktop server)? According to #64251, a newer server discards an old protocol 8 daemon and starts a fresh one, and the old daemon exits on its own. If you still see zombies with opencode-pty 0.6.0, please say so on #63817.

    I'm closing this issue now as a duplicate of #63817. Please add any further details there. If you reply here, this issue will reopen.

  2. opencodejr
    closed this as a duplicateof pty: shell commands leave zombies under opencode-pty daemon on Linux (2.3.0) #63817 on Nov 22, 2026
  3. opencodejr
    added
    area/serviceBackground service and server
    platform/macosmacOS
    type/bugSomething is broken
    version/v2OpenCode 2.x
    on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/serviceBackground service and serverplatform/macosmacOStype/bugSomething is brokenversion/v2OpenCode 2.x

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.