[launchd-dev] OnDemand USB Software

Mike Fischer mike_fischer at mac.com
Tue Apr 1 08:06:15 PDT 2008


Am 01.04.2008 um 13:34 schrieb Quinn <eskimo1 at apple.com>:
> 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.

Sure, glad to help. FWIW it came back as duplicate of <rdar:// 
3886256> which seems rather old judging by the number.


> IMHO the best example of how to use launchd with a UNIX domain  
> socket is:
>
> <http://developer.apple.com/samplecode/BetterAuthorizationSample/ 
> index.html>

I never would have thought to look there ;-) Interesting sample  
though. Thanks for the tip.


>> 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.

OK. BetterAuthorizationSample does a good job of demonstrating this.


>> 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.

Ah, I see now. Makes sense in retrospect.


Again thanks for your help!

Mike
-- 
Mike Fischer         Softwareentwicklung, EDV-Beratung
                                     Schulung, Vertrieb
Web: <http://homepage.mac.com/mike_fischer/index.html>
Note:                 I read this list in digest mode!
           Send me a private copy for faster responses.



More information about the launchd-dev mailing list