Child process

Source: Wikipedia, the free encyclopedia.

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 systems and the POSIX 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

OS/360 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 (1978), from RSX-11
(1972).

Children created by fork

A child process inherits most of its

exec
) 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

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 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.[1]

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.[2] Because the child is still consuming system resources but not executing it is known as a zombie process. The wait system call is commonly invoked in the SIGCHLD handler.

BSD behaviors with regard to ignoring SIGCHLD, calling wait remains the most portable paradigm for cleaning up after forked child processes.[5]

See also

  • exit
  • pstree, for UNIX to find the child process (pstree PID, where PID is the process id of the process).

References

  1. The Single UNIX Specification, Version 4 from The Open Group
  2. ^ wait(2): wait for process to change state – Linux Programmer's Manual – System Calls
  3. ^ "The Linux kernel: Signals". Win.tue.nl. Retrieved 2014-04-30.
  4. ^ [1] Archived September 29, 2011, at the Wayback Machine
  5. ^ sigaction(2): examine and change a signal action – Linux Programmer's Manual – System Calls

External links