[launchd-dev] OnDemand USB Software

Quinn eskimo1 at apple.com
Tue Apr 1 04:32:01 PDT 2008


At 22:02 +0100 29/3/08, Mike Fischer wrote:
>BTW: The launchd.plist(5) man page contains references to a 
>launch(3) man page (10.5.2, Xcode 3.0 as well as 10.4.11, Xcode 
>2.4.1). Unfortunatly the launch(3) man page does not seem to exist. 
>Filed as <rdar://5830171>. I saw /usr/include/launch.h and the 
>SampleD sample code but these don't really explain what is going on 
>and how to properly check-in with launchd. Any hints on where to get 
>more information?

Thanks for all those bug reports.  We appreciate 'em.

IMHO the best example of how to use launchd with a UNIX domain socket is:

<http://developer.apple.com/samplecode/BetterAuthorizationSample/index.html>

>If I understand this correctly I would not be using the socket for 
>actual communication, just for triggering the launch of the 
>"server", i.e. the real (on demand) daemon?

That's the idea, yes.

>Would I need to add the SockFamily or SockProtocol keys and if so 
>what would be the correct values for a UNIX domain socket?
>Anything else I'd need to add?

o SockFamily == Unix

o SockPathMode is typically 438 (0666, rw-rw-rw-) -- This may not 
strictly be necessary in your case because the code that's connecting 
is privileged.

o SockNodeName == ??? -- It's generally best to put this in a 
privileged location (/var/run/) rather than in /tmp.

>In the real daemon I'd do a socket(2), bind(2), accept(2) (the 
>listen(2) is already done by launchd I gather)? Or do I need this at 
>all?

In a launchd daemon you don't need to do the socket, or the bind, or 
the listen.  You just get a file descriptor for the socket from 
launchd (using LAUNCH_KEY_CHECKIN) and accept connections from that.

S+E
-- 
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware


More information about the launchd-dev mailing list