Skip to content

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

@z1243161996

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions