[launchd-dev] Diagnosing launchd daemon failure to launch

Ned Hogan nedly at mac.com
Fri Nov 7 07:13:07 PST 2008

I am confused, I thought the purpose of setting the sticky bit on /var/ 
tmp was so you could count on your files being persistent there? What  
comes along and cleans out this directory?

This is not to say your suggestion to to move to /var/run is not  
valid, but the code I inherited uses /var/tmp based on the security  
concerns at the time.

The daemon, now best described as a LaunchAgent on Leopard that is in  
production I want to move to the launchd model from it's current  
StartupItems implementation. However I am not quite clear on how to  
let the domain socket listener know that I have been killed and  
restarted, is it my job to kill off the listener and restart, or could  
I create another another launchd task to watch for the creation of a  
new domain socket and would cause the listener to reconnect? For  
security reasons you do want to create a new domain socket, right?

In testing I have also noticed that I can loop when launched, how  
would I set a limit or a backoff with a runaway launchd process?

Ned Hogan
MacCruzIn Enterprises, Inc.
Apple Certified System Administrator
XSAN/Open Directory Certified
Apple Developer Connection Select

On Nov 6, 2008, at 11:04 AM, Damien Sorresso wrote:

> On Nov 6, 2008, at 10:37 AM, Iain Delaney wrote:
>> Ahh, that was the problem. So the real issue is that my daemon is  
>> loading, but not responding to my client app.
>> I'm trying to use Distributed Objects on top of UNIX Domain  
>> sockets. The directory for the socket is /var/tmp, and the client  
>> and server can communicate if I run both programs inside XCode.  
>> However, when I move the daemon program to /Library/ 
>> PrivilegedHelperTools and copy to plist into /Library/LaunchDaemons  
>> everything stops working. The client seems to be hanging while  
>> trying to connect to the socket.
>> Any ideas what I'm doing wrong?
> I would highly recommend choosing a more stable location for your  
> socket, first of all. /var/tmp gets cleaned out periodically; I'd  
> suggest /var/run, which is only cleaned out at boot-time.
> Also, have you specified the socket in your daemon's  
> launchd.plist(5), and does your daemon check in with launchd to  
> obtain the descriptor for the socket? If the answer to either of  
> these questions is "No", please see the SampleD project.
> http://developer.apple.com/samplecode/SampleD/listing3.html
> -- 
> Damien Sorresso
> BSD Engineering
> Apple Inc.
> _______________________________________________
> launchd-dev mailing list
> launchd-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev

More information about the launchd-dev mailing list