MacOS – What exactly is the purpose of TimeOut key in launchd plist

launchdmacosplist

What exactly is the purpose of 'TimeOut' key in launchd plist? I thought a program specified through the first parameter of ProgramArguments will be executed after waiting seconds specified as the value of 'TimeOut'. But this is not happening. I am using Mac OS X version 10.8.2.

The Plist I used is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>Label</key>
 <string>script.test2</string>
 <key>ProgramArguments</key>
 <array>
   <string>/bin/sh</string>
   <string>/var/scripts/test2.sh</string>
 </array>
 <key>RunAtLoad</key>
 <true/>
 <key>StandardOutPath</key>
 <string>/tmp/test2_script.out</string>
 <key>StandardErrorPath</key>
 <string>/tmp/test2_script.err</string>
 <key>TimeOut</key>
 <integer>600</integer>
</dict>
</plist>

What I may be doing wrong here?

Best Answer

Launchd just passes the TimeOut value to the job. This is different from ExitTimeOut, which is used by Launchd to send a KILL signal to the job. Your specific requirement should be implemented within your job.

From a post in June 2010 in the Darwin-Kernel mailing list:
Re: What is TimeOut ("idle time out") in launchd?

This specifies the idle exit timeout. If your daemon hasn't received a request in this amount of time, it should quit. Notably launchd does not implement this for you; it's up for you to implement the timeout in your daemon's main event loop.