On macOS 27.x (Apple silicon) I've been measuring how launchd stops a job, and two
behaviors don't match the documentation.
Method: a throwaway job whose script traps SIGTERM and logs it, bootstrapped with different
ExitTimeOut values, then stopped with launchctl bootout while timing when the process dies.
Observed (LaunchAgent in the gui domain; the same results in the system domain with a
LaunchDaemon):
ExitTimeOut 45 -> `launchctl print` reports 45; SIGTERM, then SIGKILL at 45 s
ExitTimeOut 61 -> reports 60; SIGTERM, then SIGKILL at 60 s
ExitTimeOut 90 -> reports 60; SIGTERM, then SIGKILL at 60 s
ExitTimeOut 120 -> reports 60; SIGTERM, then SIGKILL at 60 s
ExitTimeOut 0 -> reports 0; SIGKILL after ~0.1 s, SIGTERM never delivered
man launchd.plist says of ExitTimeOut:
"The amount of time launchd waits between sending the SIGTERM signal and before sending a
SIGKILL signal when the job is to be stopped. The default value is system-defined. The
value zero is interpreted as infinity and should not be used, as it can stall system
shutdown forever."
So: is there a 60-second ceiling on ExitTimeOut? It isn't documented that I can find, and it
applies in both domains. And is zero meant to be "infinity" as documented, or an immediate
SIGKILL as observed? Finally, is there a supported way for a service to be given more than
60 seconds to exit when launchd stops it — or is 60 seconds simply the maximum?
Happy to file a Feedback with a minimal repro if that's useful.
is there a 60-second ceiling on ExitTimeOut?
Yes.
AFAICT this was introduced in macOS 26.4 (r. 47130898). This change probably should be documented in the launchd.plist man page, and I encourage you to file a bug to that effect.
Please post your bug number, just for the record.
Keep in mind that the resulting documentation might well end up being quite vague, just like it is for the current default value, because it’s easy to imagine this limit changing again in the future. This 60 second value is way too long IMO. Jobs should be able to exit much quicker than that.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"