About the ExitTimeOut key in a daemon's configuration plist
Hello, From launchd.plist(5): ExitTimeOut <integer> 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. Since I’m considering a service that may sometimes need somewhat more time than the default wait time (10 seconds, IIRC), I tried with: <key>ExitTimeOut</key> <integer>60</integer> in the service’s plist. No problem with a "launchctl bootout": the daemon receives a TERM signal and shuts down cleanly. But when rebooting the machine, it seems that the system doesn’t send a TERM signal: it just waits for sixty seconds, then KILLs the daemon. On the other hand, without the ExitTimeOut key in the plist, the TERM signal is sent to the daemon upon reboot (as expected). This is with Mac OS X 10.11.3. Am I misunderstanding the role of that ExitTimeOut key? TIA, Axel
Axel, Your understanding is correct. My guess is that your daemon is, for whatever reason, not processing the SIGTERM launchd sends at shutdown. You might want to give you signal handling code a second look. If you're not already I'd recommend using dispatch(3) to handle the signal. -damien
On Mar 12, 2016, at 02:22, Axel Luttgens <axel.luttgens@skynet.be> wrote:
Hello,
From launchd.plist(5):
ExitTimeOut <integer> 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.
Since I’m considering a service that may sometimes need somewhat more time than the default wait time (10 seconds, IIRC), I tried with:
<key>ExitTimeOut</key> <integer>60</integer>
in the service’s plist.
No problem with a "launchctl bootout": the daemon receives a TERM signal and shuts down cleanly.
But when rebooting the machine, it seems that the system doesn’t send a TERM signal: it just waits for sixty seconds, then KILLs the daemon.
On the other hand, without the ExitTimeOut key in the plist, the TERM signal is sent to the daemon upon reboot (as expected).
This is with Mac OS X 10.11.3.
Am I misunderstanding the role of that ExitTimeOut key?
TIA, Axel
_______________________________________________ launchd-dev mailing list launchd-dev@lists.macosforge.org https://lists.macosforge.org/mailman/listinfo/launchd-dev
Le 8 avr. 2016 à 17:38, Damien Sorresso a écrit :
Axel,
Your understanding is correct. My guess is that your daemon is, for whatever reason, not processing the SIGTERM launchd sends at shutdown. You might want to give you signal handling code a second look. If you're not already I'd recommend using dispatch(3) to handle the signal.
-damien
On Mar 12, 2016, at 02:22, Axel Luttgens wrote:
Hello,
From launchd.plist(5):
[…]
This is with Mac OS X 10.11.3.
Am I misunderstanding the role of that ExitTimeOut key?
Hello Damien, Thank you for your kind follow-up. I thus tried again today with the same daemon/plist, and… it works as expected. The only difference is that I installed Mac OS X 10.11.4 on March 16th. Could it be that some launchd bug has been corrected with 10.11.4? Axel
Axel, I do not believe there have been any fixes in that area. The teardown path is pretty straightforward, and the code path is such that the SIGKILL timer won't ever be armed without first calling kill(2) with SIGTERM. -damien
On 17 Apr, 2016, at 09:23, Axel Luttgens <axel.luttgens@skynet.be> wrote:
Le 8 avr. 2016 à 17:38, Damien Sorresso a écrit :
Axel,
Your understanding is correct. My guess is that your daemon is, for whatever reason, not processing the SIGTERM launchd sends at shutdown. You might want to give you signal handling code a second look. If you're not already I'd recommend using dispatch(3) to handle the signal.
-damien
On Mar 12, 2016, at 02:22, Axel Luttgens wrote:
Hello,
From launchd.plist(5):
[…]
This is with Mac OS X 10.11.3.
Am I misunderstanding the role of that ExitTimeOut key?
Hello Damien,
Thank you for your kind follow-up.
I thus tried again today with the same daemon/plist, and… it works as expected.
The only difference is that I installed Mac OS X 10.11.4 on March 16th.
Could it be that some launchd bug has been corrected with 10.11.4?
Axel
_______________________________________________ launchd-dev mailing list launchd-dev@lists.macosforge.org https://lists.macosforge.org/mailman/listinfo/launchd-dev
Le 18 avr. 2016 à 18:02, Damien Sorresso a écrit :
Axel,
I do not believe there have been any fixes in that area. The teardown path is pretty straightforward, and the code path is such that the SIGKILL timer won't ever be armed without first calling kill(2) with SIGTERM. -damien
Thanks a lot once again, Damien. So, I sure must have been doing something wrong at one point. Sincerely I prefer this, given the crucial role of launchd… Best regards, Axel BTW, has someone already noticed that the source code of launchd isn’t available anymore? :-)
participants (2)
-
Axel Luttgens
-
Damien Sorresso