About Daemons and Services

Many kinds of tasks that do not require user interaction are most effectively handled by a process that runs in the background. You can use a daemon or service to:

Figure I-1  Daemons and services are started by launchd in two separate session contexts

At a Glance

This document provides information that developers of daemons and other low-level system services need to write their code and incorporate it into the startup process. It also provides some useful information for system administrators who must manage the startup process on the computers they manage.

Design your Background Process

OS X provides a variety of background process types with different characteristics, designed for a different situations. There are also several ways for other processes to communicate with background processes. Choosing the appropriate design for a background process is an important first step.

Implement your Background Process

Having made the design decisions, you are ready to begin writing code. These chapters guide you through the process of creating specific types of background jobs.

Logging Errors and Warnings

Logging is an effective way for background processes to record unusual behavior and error conditions. Making appropriate use of the logging mechanisms provided by OS X can assist during debugging and end-user troubleshooting.

Running Jobs on a Timed Schedule

Although it is recommended that background jobs be launched on demand, in some cases running the job on a timed schedule is the most appropriate solution.

See Also

Daemons and Agents provides additional details about implementing launch daemons and agents.

Kernel Programming Guide and Kernel Extension Programming Topics describe how to write kernel extensions and other kernel-level background processes.

Networking Overview describes the APIs available for sending and receiving data across the network.