A child process (CP) in computing is a
process
A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic.
Things called a process include:
Business and management
* Business process, activities that produce a specific s ...
created by another process (the
parent process). This technique pertains to
multitasking operating systems, and is sometimes called a subprocess or traditionally a subtask.
There are two major procedures for creating a child process: the
fork system call (preferred in
Unix-like
A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
systems and the
POSIX
The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
standard) and the
spawn (preferred in the
modern (NT) kernel of
Microsoft Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
, as well as in some historical operating systems).
History
Child processes date to the late 1960s, with an early form in later revisions of the
Multiprogramming with a Fixed number of Tasks Version II (MFT-II) form of the IBM
OS/360 operating system, which introduced ''sub-tasking'' (see
task). The current form in Unix draws on
Multics
Multics ("MULTiplexed Information and Computing Service") is an influential early time-sharing operating system based on the concept of a single-level memory.Dennis M. Ritchie, "The Evolution of the Unix Time-sharing System", Communications of t ...
(1969), while the Windows NT form draws on
OpenVMS
OpenVMS, often referred to as just VMS, is a multi-user, multiprocessing and virtual memory-based operating system. It is designed to support time-sharing, batch processing, transaction processing and workstation applications. Customers using Op ...
(1978), from
RSX-11
RSX-11 is a discontinued family of multi-user real-time operating systems for PDP-11 computers created by Digital Equipment Corporation. In widespread use through the late 1970s and early 1980s, RSX-11 was influential in the development of later ...
(1972).
Children created by fork
A child process inherits most of its
attributes, such as
file descriptor
In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket.
File descriptors typically h ...
s, from its parent. In
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
, a child process is typically created as a copy of the parent, using the
fork system call. The child process can then overlay itself with a different program (using ) as required.
Each process may create many child processes but will have at most one parent process; if a process does not have a parent this usually indicates that it was created directly by the
kernel. In some systems, including
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
-based systems, the very first process (called
init
In Unix-based computer operating systems, init (short for ''initialization'') is the first process started during booting of the operating system. Init is a daemon process that continues running until the system is shut down. It is the direc ...
) is started by the kernel at
booting
In computing, booting is the process of starting a computer as initiated via Computer hardware, hardware such as a physical button on the computer or by a software command. After it is switched on, a computer's central processing unit (CPU) h ...
time and never terminates (see
Linux startup process); other parentless processes may be launched to carry out various
daemon tasks in
userspace. Another way for a process to end up without a parent is if its parent dies, leaving an
orphan process; but in this case it will shortly be adopted by ''init''.
The SIGCHLD
signal
A signal is both the process and the result of transmission of data over some media accomplished by embedding some variation. Signals are important in multiple subject fields including signal processing, information theory and biology.
In ...
is sent to the parent of a child process when it
exits, is interrupted, or resumes after being interrupted. By default the signal is simply ignored.
Children created by spawn
End of life
When a child process terminates, some information is returned to the parent process.
When a child process terminates before the parent has called
wait, the kernel retains some information about the process, such as its
exit status, to enable its parent to call ''wait'' later.
Because the child is still consuming system resources but not executing it is known as a
zombie process
On Unix and Unix-like computer operating systems, a zombie process or defunct process is a process that has completed execution (via the exit system call) but still has an entry in the process table: it is a process in the " terminated stat ...
. The ''wait'' system call is commonly invoked in the SIGCHLD handler.
POSIX.1-2001 allows a parent process to elect for the kernel to automatically reap child processes that terminate by explicitly setting the disposition of SIGCHLD to SIG_IGN (although ignore is the default, automatic reaping only occurs if the disposition is set to ignore explicitly), or by setting the SA_NOCLDWAIT flag for the SIGCHLD signal. Linux 2.6 kernels adhere to this behavior, and FreeBSD supports both of these methods since version 5.0. However, because of historical differences between
System V and
BSD behaviors with regard to ignoring SIGCHLD, calling ''wait'' remains the most portable paradigm for cleaning up after forked child processes.
See also
*
exit
*
pstree, for UNIX to find the child process (''pstree PID'', where PID is the process id of the process).
References
External links
* {{man, 1, pstree, die.net, print process trees
Process (computing)