HOME

TheInfoList



OR:

A child process in computing is a process 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 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 Unix-li ...
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 both the system- and user-level application programming inte ...
standard) and the spawn (preferred in the modern (NT) kernel of Microsoft Windows, 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 OS/360, officially known as IBM System/360 Operating System, is a discontinued batch processing operating system developed by IBM for their then-new System/360 mainframe computer, announced in 1964; it was influenced by the earlier IBSYS/IBJOB ...
operating system, which introduced ''sub-tasking'' (see task). The current form in Unix draws on Multics (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 Ope ...
(1978), from RSX-11 (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 ...
s, from its parent. In
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser 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 Kernel may refer to: Computing * Kernel (operating system), the central component of most operating systems * Kernel (image processing), a matrix used for image convolution * Compute kernel, in GPGPU programming * Kernel method, in machine lea ...
. In some systems, including
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which i ...
-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 computer 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 button or by a software command. After it is switched on, a computer's central processing unit (CPU) has no software in its ma ...
time and never terminates (see
Linux startup process The multi-stage booting process of Linux is in many ways similar to the BSD and other Unix-style boot processes, from which it derives. Booting a Linux installation involves multiple stages and software components, including firmware initializati ...
); 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 An orphan process is a computer process whose parent process has finished or terminated, though it remains running itself. Unix-like In a Unix-like operating system any orphaned process will be immediately adopted by an implementation-defin ...
; but in this case it will shortly be adopted by ''init''. The SIGCHLD signal 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 Wait or WAIT may refer to: Music * Wait (musician), British town pipers Albums and EPs * ''Wait'' (The Polyphonic Spree EP), by The Polyphonic Spree * ''Wait'' (Emanuel Nice EP), a 2002 EP released by the band Emanuel Nice * ''Wait'' (Stee ...
, 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 state ...
. The ''wait'' system call is commonly invoked in the SIGCHLD handler.
POSIX.1-2001 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 both the system- and user-level application programming interf ...
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 pstree is a Linux command that shows the running processes as a tree. It is used as a more visual alternative to the ps command. The root of the tree is either init or the process with the given pid. It can also be installed in other Unix sy ...
, 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)