Repository navigation
proc: take a child's exit by asking too, not by SIGCHLD alone (from h04x3d's Mac fixes) - #1497
Merged
Merged
Conversation
A Mac user saw the hub restart overnight ("stopped answering", "start stalled for 1054 s")
and builds marked bad after the laptop slept. The hub stored each part's last good check by
the wall clock while its checks run on tokio's timers, which stop while the machine sleeps.
At a Power Nap DarkWake (about 2 s, every 15 minutes) every part looked hours old, the wake
was too short for the next check, and six wakes in a row ended a well hub. The guard
measured a start's stall by the phase file's wall-clock age, so a sleep counted as a stall.
- hub guard.rs: the last good checks are kept on the monotonic clock, as the timers are.
- guard run.rs: a start's stall is measured on Instant from the last change of the phase file.
- guard plan.rs SleepClock: the wall clock running >10 s past the monotonic one is a sleep;
it resets the miss count, and a failed check within 30 s of a wake is logged, not counted.
Found and first fixed by h04x3d (fix/macos-sleep on their fork); taken as is, without that
branch's child-reaping part, which main covers since e16ae77 (#1456).
Tested: guard crate tests (45, incl. plan::a_sleep_is_told_from_a_hang_by_the_two_clocks),
hub guard:: tests (25). Not run on a Mac.
Co-authored-by: h04x3d <33473989+h04x3d@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # native/guard/src/plan.rs # native/guard/src/run.rs # native/host/src/guard.rs
…04x3d) h04x3d's Mac hub missed SIGCHLD: git calls never returned (design-history captures over 120 s, #1110), account checks got stuck (#1108), and the Claude usage read left a zombie every five minutes. The root cause (a signal mask inherited from the desktop app) was fixed in e16ae77, and their sleep fix landed in main as 47c492c. This takes the rest of their branch as a backstop, so a missed signal can no longer hang the hub. - proc::wait: try_wait every 5 ms, backing off to 250 ms, raced with tokio's wait() (cancel-safe); whichever comes first wins. - proc::output: output() with the exit taken by proc::wait. It sets stdin to null as tokio's output() does, so a child that reads stdin cannot hold it. Every git and sh call in files/git.rs goes through it. - proc::kill_and_reap / kill_wait: a killed child is reaped in the background, never dropped to tokio's orphan queue. The account checks' closes, CLI calls, usage read and sign-in flow use them. On Linux (pidfd) and Windows the poll only adds a few cheap timer wakes while a child runs; wait() still answers first. Tested: hub tests for proc::, files::git, settings::accounts and guard:: (188 pass), including the new a_childs_exit_is_taken_without_sigchld_and_a_killed_child_is_reaped (stdin null, a running child's exit, a killed child reaped, kill_wait within its limit). Not run on a Mac. Co-Authored-By: h04x3d <33473989+h04x3d@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jlcjak
marked this pull request as ready for review
November 24, 2026 00:19
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.
A macOS user (h04x3d) reported strange timeouts after the Mac had been asleep:
Their fork (
h04x3d/Backplane,fix/macos-sleep) fixed two faults. This PR is now brought up to date with main (merge, not rebase) and takes everything in it that main doesn't already have.Already on main, so taken from main
SleepClock, wake grace and awake-clock stall check, plus Windows (QueryUnbiasedInterruptTime). The merge keeps main'sguard/plan.rs,guard/run.rsandhost/guard.rs.What this adds (h04x3d's child-exit fix, as a backstop)
proc::wait: askstry_waitevery 5 ms, backing off to 250 ms, raced with tokio's cancel-safewait(); whichever comes first wins.proc::output:output()with the exit taken byproc::wait. Every git andshcall infiles/git.rsgoes through it.proc::kill_and_reap/kill_wait: a killed child is reaped in the background, never dropped to tokio's orphan queue. Used by the account checks (RPC close, CLI calls, the Claude usage read, the sign-in flow).Why it shouldn't break anything
wait()still answers first (pidfd / wait handle). The poll only adds a few timer wakes, capped at 4 a second, while a child runs.try_waitwaits on that child's pid only, so it can't take another child's status.output()reads both pipes at once and then waits, as tokio's does.output()does, so a child that reads stdin can't hold it (tested). git calls already set null.kill_on_dropstill kills a git child whose read times out.Testing
proc::,files::git,settings::accountsandguard::all pass (188). They include h04x3d's test, extended foroutput()'s null stdin andkill_wait's limit.Co-authored by h04x3d.
🤖 Generated with Claude Code