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

Iceberg-Dev dev.iceberg at gmail.com
Mon Jun 29 14:44:52 PDT 2009


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


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.

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

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


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.


Questions:
----------

- Is there an example somewhere that _works_ and covers launching a  
daemon with launchd using sockets or mach port as dependencies?

- Is there a tutorial somewhere that covers this subject?

- Are these mach port and socket things really working? I dare ask  
because socket dependency was supposed to work on 10.4.0 and AFAIK,  
it was only supported way later.




More information about the launchd-dev mailing list