[launchd-dev] launchd: how is it supposed to be done?

Iceberg-Dev dev.iceberg at gmail.com
Mon Jun 29 15:31:23 PDT 2009


On Jun 30, 2009, at 12:04 AM, Damien Sorresso wrote:

> On Jun 29, 2009, at 2:44 PM, Iceberg-Dev wrote:
>> What I can do:
>> --------------
>>
>> Create a plist file for launchd to launch a tool every time at  
>> startup (even though the required plist contents are apparently  
>> changing with each OS release because it's probably more funny  
>> like that).
>
> The required plist keys have not changed since 10.4. Label,  
> ProgramArguments, Program. Please read launchd.plist(5) for  
> specifics. Don't worry too much about how Program isn't required if  
> ProgramArguments is present. Just provide them both, pretend you're  
> calling execve(2) and save yourself some headaches.
>
>> What I am trying to do:
>> -----------------------
>>
>> I'm trying to launch a helper daemon (not an agent) on demand.
>>
>> Ideally, it would work this way:
>>
>> - Process (P) needs to talk with Daemon (D)
>>
>> - Daemon (D) is launched on demand by launchd based on some socket  
>> or mach port magic.
>>
>> - (D) notifies (P) that it's ready to listen
>>
>> - (P) talks to (D). (P) does what it is supposed to do then.
>>
>> - After that (P) waits for a while and if nothing happens, it quits.
>>
>>
>> What I have tried so far:
>> -------------------------
>>
>> - Read the launchd.plist and launchdman pages. It just gives me  
>> headaches as like most man pages it assumes you know how to do  
>> something and is not didactic.
>
> I'm sorry that the documentation is so dry, but that's a common  
> feature of all technical documentation. There are some  
> deficiencies, but we try to be clear as to what each key does.  
> Which parts in particular were confusing?

I guess the #1 problem is that the Example section (ofd launchd.plist 
(5)) lacks examples. I understand that you can't put a lot of  
examples but right now (I'm looking on 10.4.10 so forgive me if it's  
not totally up to date), there is only one simple example.

>
>> - Tried the sample code from the ADC Website. It does not event  
>> built and the bug report I filed to suggest to get it fixed was  
>> probably sent to /dev/null as I haven't heard about it since.
>
> What's the Radar number? What sample code was this? (Did you  
> attempt to fix the code yourself?)

#6908216

SampleD

Didn't try fixing it since I'm in learning mode and would probably do  
more damages than anything else.

>> - Looked for sample code using google. Was not able to find a  
>> single good example. There are plenty of examples showing how to  
>> write equivalents of crontab, StartupItems but none for triggering  
>> a daemon with sockets or a mach port. Some of them apparently try  
>> to deal with file dependencies it is not clear if they are even  
>> sure with this.
>
> The lack of good Mach examples sucks, and I'm sorry that the  
> situation is the way it is. But that's really all I can say about it.
>
>> By the way:
>> -----------
>>
>> I attended the session on launchd at WWDC and was still like  
>> Alicia Silverstone in that 1995 movie after that. I must be an idiot.
>
> There was a rather extensive Q&A session after that talk, and I  
> made myself available for questions even after that. Did I talk to  
> you at all?

The topic about socket and mach port was not really covered in the  
session. So it didn't look to be a good topic for Q&A.




More information about the launchd-dev mailing list