[launchd-dev] TimeOut key — how long should a job really stay alive?

Damien Sorresso dsorresso at apple.com
Fri Aug 7 11:12:35 PDT 2009


On Aug 7, 2009, at 11:01 AM, Sidney San Martín wrote:
> I'm building a daemon that uses a launchd-provided socket, it seems
> like a good idea to exit when nothing's connected.
>
> I've read that jobs must stay alive for 60 seconds, but launchd is
> giving me a 30 second timeout at checkin. What's right? How are daemon
> timeouts supposed to work?


I'm not sure where you read that, but it sounds like someone,  
somewhere, is misunderstanding something. launchd gives each job a  
default ThrottleInterval of 10 seconds. This means that, if your job  
comes alive and then exits two seconds later and then immediately  
needs to be respawned, launchd will schedule your job to be run 8  
seconds from that point. Thus, your job's start times must be at least  
10 seconds apart by default, which establishes an effective minimum  
run time.

You can override this with the ThrottleInterval key if you'd like.

So if you have an idle exit timeout of 30 seconds, you'll be fine.
-- 
Damien Sorresso
BSD Engineering
Apple Inc.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2425 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/launchd-dev/attachments/20090807/af5f50ab/attachment.bin>


More information about the launchd-dev mailing list