Repository navigation
fix: report macOS service inspection failures instead of a stopped state - #60
Merged
Merged
Conversation
Status turned every failed "launchctl list" into a result that looked like a stopped service: timeouts, a missing launchctl, permission and domain errors were all discarded. Restart could then act on a state nobody had observed, Reload reported "not running", and diagnostics lost the real cause. Only launchctl's "Could not find service" exit status (113) now means the job is not loaded and therefore not running. A timeout is reported as such, and every other failure is returned with launchctl's output. The Linux implementation already propagated errors this way. Closes #52. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Pull request
Summary
On macOS,
Statusranlaunchctl list <label>and parsed its output only when the command succeeded; every failure returned a status that looked like a stopped service, with no error. Timeouts, a missinglaunchctl, and permission or domain errors were all discarded, so callers acted on a state nobody had observed.launchctl listfor an unknown label.launchctl list … timed out after 15s, and every other failure is returned with launchctl's own output.launchctlNotFoundhelper replaces the exit-status check thatkickstart(fix: restart the macOS service in one launchd operation #58) used.Effect on callers:
-restartstops on an inspection failure instead of acting on a guessed state;-reloadreports the real error instead of "not running";-statusreturns the error instead of printing a misleading state;-diagalready reportedStatuserrors as failures and now shows the real cause. The Linux implementation already propagated errors this way.Reporting "installed but not loaded" as a separate state, also suggested in #52, is left to #51, which covers recovering exactly that case.
Closes #52.
User impact
macOS lifecycle and status commands fail with the real
launchctlerror instead of reporting a stopped service when launchd cannot be inspected. A job that is simply not loaded is still reported as installed and not running.Validation
launchctl: running job; unloaded job (exit 113) reported as stopped without error; launchctl failure, timeout, missing executable, and malformed output each reported as errors without claiming the job is running; restart does not kickstart after an inspection failure. The fix: restart the macOS service in one launchd operation #58 restart tests that modeled "not loaded" with exit status 1 now use the real 113.Statusreports it installed and running with its PID and no error.SSH_AGENT_PROXY_REQUIRE_OPENSSH=1 go test -race ./...; twenty race-enabled repetitions of the launchd tests.go vet ./...(alsoGOOS=linux), formatting,git diff --check, and CGO-disabled builds for darwin/linux × amd64/arm64.Checklist
go test -race ./...passes locally, or the reason it was not run is documented.🤖 Generated with Claude Code