fix(daemon): preserve macOS launchd ownership during startup - #3952
Merged
Merged
Conversation
Reuse an unchanged running launch agent and reload stopped or changed registrations before replacing an unmanaged daemon. Propagate launchctl failures so unavailable launchd is not mistaken for a missing job.
Wait for the previous daemon process and instance lock to exit before loading its launch agent. Keep the old lock inode open through shutdown, so a closed listener or unlinked pathname cannot falsely signal readiness. Block unmanaged startup when shutdown or launchd ownership is unresolved, while preserving the fallback for unsupported supervisors.
Do not start an unmanaged macOS daemon after launchd accepted registration but has not opened the listener within the readiness window.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Sep 16, 2026
afonsojramos
marked this pull request as ready for review
September 16, 2026 23:38
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.
Keep macOS daemon startup under launchd ownership. Reuse an unchanged running registration, reload changed or stopped jobs, and report launchctl failures instead of treating them as missing jobs.
Before replacing an unmanaged daemon, wait for both process exit and its original instance-lock inode to be released. A closed listener or unlinked lock file does not prove exit. Apply does not spawn an unmanaged fallback while ownership is unresolved or after launchd has accepted a registration but has not started listening yet.
Validation: focused startup, process/lock-release, and launchctl parsing regressions pass. Full library tests and strict library Clippy pass. An independent review identified the shutdown race now covered by the new regressions.
Live macOS verification passed with the combined local build including #3948 and #3951. The visible Store update/Apply flow restarted Spotify and restored stdlib 1.12.0 after a published older-version fixture. Daemon PID 3060 and its launch-agent plist remained unchanged with responsive health checks. A subsequent macOS protocol URL Apply also preserved that daemon. Delayed startup and shutdown-race paths are covered by regressions, not forced in the live installation.