Skip to content

fix(opencode): zombie processes from detached shell children on Linux #29506

Closed as not planned

Description

@z1243161996

Summary

tool/shell.ts spawns child shell processes with detached: true on Linux, causing zombie processes to accumulate over multiple opencode run sessions.

Root Cause

In packages/opencode/src/tool/shell.ts:304:

detached: process.platform !== "win32",

On Linux this spawns shell processes via setsid() into their own process group/session. When these child processes exit before the parent calls waitpid(), and with no SIGCHLD handler anywhere in the codebase, they become <defunct> zombie processes.

Observed: 8 opencode run sessions accumulated 11 zombie processes. The only fix was kill -9 on the parent opencode processes.

Proposed Fix

Change line 304 to detached: false on all platforms:

detached: false,

Without setsid(), child processes remain in the parent's process group. Node.js can properly reap them when handle.exitCode resolves. Explicit process cleanup is already handled via handle.kill() in abort/timeout paths, so signal isolation via detached is unnecessary.

Also Benefits

Related

Activity

  1. github-actions commented on May 27, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If there is overlap, consider coordinating or referencing each other's findings.

  2. added a commit that references this issue on May 28, 2026
    17b0a95
  3. github-actions commented on Jul 27, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions