launchd: Better than sliced bread - Chris Hanson
Posted on March 17, 2008 in How-to
Processes launched at startup on Mac OS X are managed by launchd. There’s no careful balancing of init.d or SystemStarter scripts on modern releases of the operating system. Instead, launchd jobs have property list entries in the LaunchAgents and LaunchDaemons directories in the system and local domains. Some specify that launchd should keep them alive indefinitely, others simply provide conditions under which they should be launched.
For instance, the standard finger daemon indicates that it should be run whenever something connects to the socket corresponding to the finger service; it doesn’t run all the time, nor does it rely upon a separate “network service daemon” to launch. Similarly, the Bluetooth daemon is only run only when a particular Mach port is connected to; it doesn’t need to be running all the time, and a framework interacting with it can easily just connect to it and start using it, without worrying about the mechanics of launching it, ensuring only one instance is running, and so on.
Where launchd really shines is in the level of integration it lets developers offer between frameworks and daemons or agents when it comes to managing shared state.