Repository navigation
fix(process-daemon): wait for readiness instead of polling - #59701
Merged
Merged
Conversation
3 of 6 tasks
jlongster
force-pushed
the
daemon-control
branch
from
October 27, 2026 19:55
a1ce868 to
aeeb1e2
Compare
jlongster
force-pushed
the
daemon-poll-loop
branch
from
October 27, 2026 19:55
4490c9c to
3aaa646
Compare
jlongster
force-pushed
the
daemon-control
branch
from
October 27, 2026 20:07
aeeb1e2 to
b3c1e19
Compare
jlongster
force-pushed
the
daemon-poll-loop
branch
from
October 27, 2026 20:07
3aaa646 to
c7d57b8
Compare
jlongster
force-pushed
the
daemon-control
branch
from
October 27, 2026 22:21
b3c1e19 to
689be3e
Compare
jlongster
force-pushed
the
daemon-poll-loop
branch
from
October 27, 2026 22:22
c7d57b8 to
870a490
Compare
jlongster
force-pushed
the
daemon-control
branch
from
October 27, 2026 22:33
689be3e to
20dd8f4
Compare
jlongster
force-pushed
the
daemon-poll-loop
branch
from
October 27, 2026 22:33
870a490 to
aa3190b
Compare
jlongster
force-pushed
the
daemon-poll-loop
branch
from
October 28, 2026 00:52
aa3190b to
275ff87
Compare
alsuren
pushed a commit
to alsuren/opencode
that referenced
this pull request
Oct 28, 2026
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.
Ported from anomalyco/opencode-pty#31. Part of the stack for anomalyco/opencode-pty#25; builds directly on
dev(#59700 has merged), no prerequisite.Issue for this PR
Fixes anomalyco/opencode-pty#25 (this PR completes it)
Type of change
What does this PR do?
poll(2)on the listener plus a private wake channel (UnixStream::pair, non-blocking,CLOEXEC) instead of a 10 ms sleep. The timeout is the minimum of the next ownership deadline, a 2 s safety net, and the accept back-off.Controlnotifies under the ownership mutex for every stop/ownership mutation.Control::tickdrains the wake channel, observes, detects missed wakes, and ticks under the same lock, so a missed wake is detected deterministically (a warning in release builds; an error in debug builds, with cleanup still running).EMFILE,ENFILE,ENOBUFS,ENOMEM) from accept or cancellation now pause accept for 100 ms instead of killing the daemon.WaitForMultipleObjectson the connect event plus a stop event, and replacing the per-terminal 10 ms root-exit poll.pollfeature ofnixinpackages/process-daemon/Cargo.toml(no new crates;Cargo.lockis unchanged).Ported from the opencode-pty commit; the only difference is that connection handlers are spawned with plain
thread::spawn, as ondev.Measurement (macOS, debug builds, idle owned daemon)
Tests added
packages/process-daemon/src/daemon/server.rs:owned_handoff_expiry_keeps_daemonidle_loop_does_not_spinconnect_does_not_wait_for_timeouthandler_completion_closes_socket_promptlymissed_wake_is_detectedmissed_disconnect_is_detectednotify_storm_is_not_missedpackages/process-daemon/src/ownership.rs:deadline_tracks_each_statepackages/process-daemon/src/transport/unix.rs:wake_is_cloexec_and_nonblockingwake_notify_never_blocks_and_drain_emptieslistener_wait_reports_each_sourcelistener_wait_rounds_timeout_upMutation checks (original PR)
Done) notify failshandler_completion_closes_socket_promptly.update_ownershipnotify failsowned_handoff_expiry_keeps_daemon.ticknotify failsidle_loop_does_not_spin,missed_wake_is_detected, andmissed_disconnect_is_detected.Flakiness runs (original PR)
How did you verify your code works?
packages/process-daemon):cargo fmt --check,cargo clippy --locked --all-targets --all-features -- -D warnings, andcargo test --locked --lib(65 passed) pass.daemon-windows-poll) the full macOS CI test selection and Windows/Linux cross clippy also pass, and the server module tests (13) passed 3 runs in a row.cargo test --locked --lib --test service --test runtime --test ownership --test rows --test ghostty-effects(lib 59, ghostty-effects 5, ownership 8, rows 1, runtime 8 + 1 ignored, service 9), and cross clippy with-D warningspassed forx86_64-pc-windows-msvcandx86_64-unknown-linux-gnu(--all-targets --all-features, ghostty-vt link libs stubbed). Native Windows and Linux rely on CI.Screenshots / recordings
N/A, internal daemon change.
Checklist