← ALL TILS
TIL

launchd caches a codesigning verdict until you bootout

launchd holds onto the codesigning verdict it formed when a job was registered. Ship a rebuilt binary to the same path and the job dies on spawn with a stale verdict. The fix is bootout plus bootstrap, not another restart.

A LaunchAgent that had run for weeks began dying the moment it spawned, right after I shipped a rebuilt binary to the same path. The plist was untouched. codesign --verify passed on the new binary. launchd killed the job anyway.

The cause: launchd does not re-evaluate a job's code signature just because the file changed on disk. The verdict it formed when the job was registered stays attached to the registration. Replace the binary and the job carries the stale verdict until the registration itself is rebuilt.

So the fix is to tear down and re-register the job, not to re-sign or re-copy the binary:

launchctl bootout gui/$UID ~/Library/LaunchAgents/com.example.worker.plist
launchctl bootstrap gui/$UID ~/Library/LaunchAgents/com.example.worker.plist

launchctl kickstart -k only restarts the process; it inherits the cached verdict. bootout plus bootstrap forces a fresh evaluation.

macoslaunchdcodesigningops