Repository navigation
fix(process-daemon): reap shell commands at exit (protocol 9, release 0.6.0) - #64266
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
I found nothing that blocks a merge. On Linux, the pull request reaps finished commands' leaders and keeps every record.
How I checked
- I wrote a test that runs 20 finished pipe commands (half
exit 0, halfexit 3) and counts zombie leaders under/proc. On the base there were 20 zombies and 20 records; with this pull request, 0 zombies and 20 records. - With a subreaper (this container's PID 1 doesn't reap orphans),
cargo test --test pipepasses 23/23 on both base and head, and the fullcargo testpasses on head. cargo fmt --checkand strictcargo clippypass.- I couldn't run Windows or macOS.
Public API
This changes only the daemon's interface with core, not the SDK, HTTP API, plugins, config or CLI:
- the protocol goes from 8 to 9 (message shapes unchanged);
@opencode/ptygoes from 0.5.2 to 0.6.0;- signalling a finished command now does nothing and succeeds, where before it reached what was left of its process group;
- deleting a finished successful command no longer kills its background processes.
Daemon and client must use the same protocol, so 0.6.0 and a protocol 8 client reject each other. Nothing breaks until a consumer pins 0.6.0, and #64251 handles that upgrade.
The 3-second SIGKILL follow-up uses the numeric group ID, the same small reuse risk as the old spawner, which the description already covers. I have no other concerns.
jlongster
force-pushed
the
pty-reap-daemon
branch
2 times, most recently
from
November 16, 2026 21:38
f7442bd to
18c7650
Compare
… background processes User decisions: - Restore the pre-2.3.0 behavior: background processes a finished command leaves behind are not tracked - Kill a failed command's process group at exit, on every platform including Windows - Reap at exit so no zombies or held handles remain - Bump the daemon protocol so upgrades replace the old daemon - Release the daemon first, then pin it in core in a separate PR
User decisions: - Release 0.6.0 for protocol 9 - Pin the published package in core in a separate PR
jlongster
enabled auto-merge (squash)
November 16, 2026 21:38
3 tasks done
mvanhorn
added a commit
to mvanhorn/opencode
that referenced
this pull request
Nov 17, 2026
Resolve the conflict with anomalyco#64266 in pipe/windows.rs by keeping both Job::assign and the new Job::finish.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Daemon half of #64251. Jay reported zombie shell commands under
opencode-ptyon macOS after upgrading to OpenCode 2.3.0. Daemon 0.5.2 deferredwaitpiduntil the command record was forgotten, so each retained record could keep a zombie for days.Type of change
What does this PR do?
Reap each command at exit and retain its output, metadata and exit status. A successful command’s background processes survive late signals and deletion. On nonzero exit, Unix sends SIGTERM to the group before reaping the leader and escalates surviving members after three seconds; Windows terminates the job immediately. Windows releases the process and job handles at exit. Running commands can still be interrupted or stopped.
The Windows regression test now checks that the PowerShell grandchild survives a late signal and deletion, then terminates it explicitly. The noisy drain test also owns its grandchild’s cleanup if an assertion fails.
Release order: merge this daemon PR → tag
process-daemon-v0.6.0→ the release workflow publishes the binaries and npm packages. After publication, #64251 becomes the core half: it pins@opencode/pty@0.6.0and handles the protocol 8 → 9 upgrade. Core, CLI and server currently pin 0.5.2.How did you verify your code works?
/bin/sh -c "exit 0"commands against each Linux daemon and checked the leaders in/procwhile all 60 records were still listed. Published 0.5.2: 60 zombies. This 0.6.0 binary: 0 zombies.cargo test --lockedpassed 147 tests (one ignored subprocess fixture). macOS ARM64cargo check --testspassed. Windows x64cargo check --testsand strict test Clippy passed using Ghostty’s-Dsimd=falsefor this Linux cross-check (no MSVC C++ headers). The local binary reportsopencode-pty 0.6.0 (protocol 9).bun run check: 35/35 tasks with the pinned Bun 1.4.4.Screenshots / recordings
Process lifecycle change; evidence above.
Checklist
Added by the opencode bot (AI-generated).
Related: #63817, #63976, #64177
Public API: opencode-pty protocol 8 → 9 and @opencode/pty 0.5.2 → 0.6.0. Signals to finished commands now do nothing and deleting a finished successful command spares its background processes. Not compatible with protocol 8 clients until core is upgraded (#64251).