macOS: wait for the old launchd job before reloading the daemon

Re-running the installer on a Mac failed with "Bootstrap failed: 5:
Input/output error". bootout returns while the old job is still stopping,
and the bootstrap right after it fails. setup.sh now lints the plist, waits
until launchctl print no longer finds the job, re-enables it (a disabled job
also fails with error 5), retries the bootstrap once, and names the commands
to check if it still fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-04 20:18:43 -08:00
parent 380243545c
commit 03604c8367
2 changed files with 19 additions and 1 deletions

View file

@ -158,3 +158,11 @@ def test_macos_daemon_runs_as_root():
setup = (ROOT / "native" / "setup.sh").read_text()
plist = setup[setup.index("<plist"):setup.index("</plist>")]
assert "<key>UserName</key>" not in plist
def test_macos_reload_waits_for_the_old_job():
"""bootstrap right after bootout fails with "5: Input/output error" while the old job stops."""
setup = (ROOT / "native" / "setup.sh").read_text()
reload = setup[setup.index('launchctl bootout "system/$SERVICE"'):]
assert reload.index('launchctl print "system/$SERVICE"') < reload.index("launchctl bootstrap system")
assert reload.index('launchctl enable "system/$SERVICE"') < reload.index("launchctl bootstrap system")