Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

launchd(8) [mojave man page]

launchd(8)						    BSD System Manager's Manual 						launchd(8)

NAME
launchd -- System wide and per-user daemon/agent manager DESCRIPTION
launchd manages processes, both for the system as a whole and for individual users. The primary and preferred interface to launchd is via the launchctl(1) tool which (among other options) allows the user or administrator to load and unload jobs. Where possible, it is preferable for jobs to launch on demand based on criteria specified in their respective configu- ration files. launchd also manages XPC services that are bundled within applications and frameworks on the system. During boot launchd is invoked by the kernel to run as the first process on the system and to further bootstrap the rest of the system. You cannot invoke launchd directly. NOTES
On Darwin operating systems, the canonical way to launch a daemon is through launchd as opposed to traditional POSIX and POSIX-like mecha- nisms or mechanisms provided in earlier versions of OS X. These alternate methods should be considered deprecated and not suitable for new projects. In the launchd lexicon, a daemon is, by definition, a system-wide service of which there is one instance for all clients. An agent is a ser- vice that runs on a per-user basis. Daemons should not attempt to display UI or interact directly with a user's login session. Any and all work that involves interacting with a user should be done through agents. XPC services which are marked with a ServiceType of System are functionally equivalent to daemons and run in the same environment, sharing the same Mach bootstrap namespace. XPC services which are marked with a ServiceType of User are equivalent to agents with the LimitLoadToSes- sionType key specifying the Background session and run in the same environment, sharing the same Mach bootstrap namespace. See launchd.plist(5) for more information about user sessions. On Darwin platforms, a user environment includes a specific Mach bootstrap subset, audit session and other characteristics not recognized by POSIX. Therefore, making the appropriate setuid(2) and setgid(2) system calls is not sufficient to completely assume the identity for a given user. Running a service as a launchd agent or a per-user XPC service is the only way to run a process with a complete identity of that user. FILES
~/Library/LaunchAgents Per-user agents provided by the user. /Library/LaunchAgents Per-user agents provided by the administrator. /Library/LaunchDaemons System-wide daemons provided by the administrator. /System/Library/LaunchAgents Per-user agents provided by Apple. /System/Library/LaunchDaemons System-wide daemons provided by Apple. SEE ALSO
launchctl(1), launchd.plist(5), DEVELOPER DOCUMENTATION
The Daemons and Services Programming Guide can be found at the following URL: https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/Introduction.html Darwin 25 November, 2013 Darwin

Check Out this Related Man Page

launch(3)						   BSD Library Functions Manual 						 launch(3)

NAME
launchd APIs -- interfaces for interacting with a launchd job. SYNOPSIS
#include <launch.h> #include <servers/bootstrap.h> kern_return_t bootstrap_check_in(mach_port_t bp, const name_t service_name, mach_port_t *sp); int launch_activate_socket(const char *name, int **fds, size_t *cnt); DESCRIPTION
A launchd(8) job may have resources that are held on behalf of it while it is not running to facilitate launch-on-demand. These interfaces allow for the job to retrieve these resources as part of its initialization. Currently supported resource types are XPC listener connections, Mach ports, and sockets. Use of XPC with launchd(8) is documented in the xpc(3) family of manual pages. MACH PORTS
The bootstrap_check_in() routine allows for a launchd(8) job to retrieve the receive right to a Mach port that launchd(8) has created on behalf of the job. launchd(8) creates this port and advertises it in the appropriate Mach bootstrap namespace by parsing the MachServices entry of the job's launchd.plist(5). The first argument to bootstrap_check_in() should always be the bootstrap_port() global. The second argument should be the name of the service whose port you wish to retrieve, as specified as an entry in the job's MachServices dictionary. The final argument, upon successful return, will be the name of the receive right corresponding to the port that launchd(8) had advertised in the bootstrap namespace. If the job closes the receive right to the port with mach_port_mod_refs() or exits, the receive right obtained by this routine will be send back to launchd(8) rather than being closed. This allows launchd to resume advertising the same port in the Mach bootstrap namespace and frees clients from the need to re-query for the send right to that port when the job dies. SOCKETS
The launch_activate_socket() routine allows a launchd(8) job to retrieve a set of file descriptors corresponding to a socket service that launchd(8) has created and advertised on behalf of the job by parsing the Sockets entry in the job's launchd.plist(5). The first argument should be the name of the socket entry as specified in the launchd.plist(5). The second argument, upon output, will point to an array of integers whose count is filled into the third argument upon success. This array represents all the sockets that launchd(8) created corre- sponding to the entry in the job's Sockets dictionary. Depending on the properties specified, a single Sockets entry may have multiple descriptors created for it (one for IPv4 and one for IPv6, for example). This array is allocated on the heap, and it is the caller's respon- sibility to call free(3) to dispose of the memory when it is no longer needed. RETURN VALUES
If launch_activate_socket() succeeds, zero is returned. In the event of failure, a non-zero POSIX-compatible error code indicating the nature of the error is returned. This error may be decoded with strerror(3). If bootstrap_check_in() succeeds, KERN_SUCCESS is returned. In the event of failure, a non-zero error code that may be decoded with bootstrap_strerror(). ERRORS
bootstrap_check_in() will fail if: [BOOTSTRAP_UNKNOWN_SERVICE] The Mach service name specified does not exist in the caller's launchd.plist(5). [BOOTSTRAP_SERVICE_ACTIVE] The specified Mach service has already been checked in by the job. launch_activate_socket() will fail if: [ENOENT] The socket name specified does not exist in the caller's launchd.plist(5). [ESRCH] The calling process is not managed by launchd(8). [EALREADY] The specified socket has already been activated. SEE ALSO
xpc(3), xpc_connection_create(3), socket(2), launchd(8), launchd.plist(5). Darwin 31 March, 2014 Darwin
Man Page