[launchd-dev] process dependancies

Kevin Van Vechten kvv at apple.com
Sun Mar 11 11:45:44 PDT 2007


On Mar 11, 2007, at 10:39 AM, Joël Brogniart wrote:

> A nice feature of SystemStartup is the notion of dependancies, ie  
> the ability to spécify that a process is dependant of other  
> processes. I don't see anything similar in launchd documentation.  
> Do I have missed something in the doc or this feature doesn't exist  
> with launchd?

Hi Joël,

There's a relatively large conceptual change with launchd that can  
easily be missed.

With SystemStarter, a "dependency" was merely a means to order the  
execution of StartupItem scripts.  It was more flexible, but not more  
powerful, than executing a set of scripts in a directory in lexical  
order.  The became problematic when a script changed between releases  
(due to underlying technology changes).  The behavior you got while  
depending on "Network" in 10.2 might not exactly correspond to the  
behavior you got while depending on "Network" on 10.3.

The key concept to launchd is to use actual operating system  
primitives for dependencies, not just names.  What does that mean?   
Well, in practical terms, a process really doesn't depend on another  
process unless it communicates with it in some way.  Let's say you  
have a process that depends on the PostgreSQL database -- that  
essentially boils down to the process assuming that Postgres' UNIX  
domain socket exists (/tmp/.s.PGSQL.4321).

The launchd approach means that the Postgres property list specifies  
that UNIX domain socket.  During startup, launchd initializes all of  
the UNIX domain sockets, network sockets, mach services, etc.  When  
your process runs, it can successfully connect the Postgres socket.   
This connection, in turn, triggers launchd to start up Postgres on  
demand.  The calling process blocks until Postgres bring-up is  
complete, then Postgres services the request, and the "dependency"  
has been fulfilled.

It's akin to virtual memory paging -- where a large address space is  
always virtually available, and actual use of pages cases the page to  
be brought into memory as necessary.  Launchd strives to make all  
system services virtually available, and start them as they are  
required.

- Kevin


More information about the launchd-dev mailing list