macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

An Introduction to Tiger Terminal, Part 5
Pages: 1, 2, 3, 4, 5

The New . . .

Now it's time to look at launchd. The launchd framework/system is actually made up of the daemon launchd and launchctl, the utility that interfaces with launchd. With launchctl, we can load and unload daemons/agents (also known as jobs) and otherwise control launchd through environment settings, logging, system resource usage stats and starting/stopping launchd jobs (also known as agents!). Now, let's use launchctl to see what jobs are loaded into launchd:



figure 14
Figure 14. sudo launchctl list

When Mac OS X boots, the BootROM checks a test of the hardware and then activates Open Firmware which selects the operating system. Next, BootX loads the kernel and drivers and then the kernel loads launchd. launchd runs /etc/rc which runs SystemStarter which, in turn, runs a series of scripts found in both /System/Library and /Library. launchd then scans through /System/Library/LaunchDaemons and /Library/LaunchDaemons for plist files (more on this in a bit), runs the necessary plist files and then starts loginwindow. launchd manages daemons during startup and continues running until shutdown.

Let's head over to /System/Library/LaunchDaemons . . . via the command line, now! Type ls to see what's here. Notice the difference between the daemons available (Figure 15 below) and the daemons actually loaded (Figure 14 above).

figure 15
Figure 15. /System/Library/LaunchDaemons

So we see that each of the periodic jobs have been replaced by three launch daemons in plist format. Huh? The Property List, or plist, format is used in Mac OS X/Darwin to store application user preferences and system configuration files in XML (eXtensible Markup Language). plists are human- and computer-readable plain text files. You create an XML file using the plist format. Then, you use launchctl to load the file into launchd.

There are different specific locations for the launchd XML files depending on whether they are for system-wide agents (/Library/LaunchDaemons), per-user agents (provided by the user: ~/Library/LaunchAgents; provided by the administrator: /Library/LaunchAgents), system-wide installed by the OS (/System/Library/LaunchAgents), etc.

Pages: 1, 2, 3, 4, 5

Next Pagearrow