Startup Scripts and Startup Items
After launchd executes successfully, it runs the
/etc/rc script to perform basic system initialization tasks. These
initialization tasks include a file-system consistency check
(fsck) and starting a process called SystemStarter, which
launches the startup items.
Startup items are processes that run during the
last phase of the startup sequence to prepare a Mac OS X system for
normal operation. Startup items consist of programs, including
customizable shell scripts, which perform tasks such as starting
additional system daemons.
System startup items are located in
/System/Library/StartupItems, and consist of folders each
containing (at a minimum) one program (typically a shell script)
whose name matches the folder's name, and a configuration property
list (plist) file that the shell script reads when the startup item
loads.
NOTE
Administrator users should not add startup
scripts to /System/Library/StartupItems. However, you can create
and store custom startup items in /Library/StartupItems.
As mentioned earlier, launchd items are intended
to replace startup items. However, Mac OS X 10.4 still supports
startup items to provide compatibility with existing software.
Launchd items, startup items, and any
applications that launch before the loginwindow process are
referred to as system processes.
These applications provide services to all users of the system and
are usually children of launchd.
(A child process is a process that
is started by another process, which is called its parent.) Processes created after the launching
of loginwindow are referred to as user
processes. User processes are always associated with a
particular user session, and are usually children of the session's
Window Manager process. You specify which user processes to launch
after login in the Login Items pane of Accounts preferences, as
discussed in Lesson 3,
"User Accounts."
Many startup scripts rely on system
configuration information stored in /etc/hostconfig. Some entries
in hostconfig specify whether certain services should be started
when the computer starts up. For example, when you turn on Personal
Web Sharing, the Services pane of Sharing preferences sets an entry
in hostconfig:
WEBSERVER=-YES-
When the Apache startup item executes during
system startup, it checks whether the WEBSERVER value is set to
YES, and if so, it starts the Apache web server.
A number of processes are already running by the
time the user logs in to a Mac OS X system. Most of these processes
are daemons or processes created by the system that run in the
background. In addition to those started by launchd and startup scripts, a
handful of processes are created on behalf of the user by the
loginwindow process and the Window Manager daemon.
|