Orphan process
Encyclopedia
An orphan process is a computer process
whose parent process
has finished or terminated
, though itself remains running.
In a Unix-like
operating system
any orphaned process will be immediately adopted by the special init
system process. This operation is called re-parenting and occurs automatically. Even though technically the process has the "init" process as its parent, it is still called an orphan process since the process that originally created it no longer exists.
A process can be orphaned unintentionally, such as when the parent process terminates or crashes. The process group
mechanism in most Unix-like operation systems can be used to help protect against accidental orphaning, where in coordination with the user's shell
will try to terminate all the child processes with the SIGHUP
process signal, rather than letting them continue to run as orphans.
A process may also be intentionally orphaned so that it becomes detached from the user's session and left running in the background; usually to allow a long-running job to complete without further user attention, or to start an indefinitely running service. Under Unix, the latter kinds of processes are typically called daemon processes
. The Unix nohup
command is one means to accomplish this.
With remote invocation, a server process is also said to be orphaned when the client that initiated the request unexpectedly crashes after making the request while leaving the server process running.
These orphaned processes waste server resources and can potentially leave a server starved for resources. However there are several solutions to the orphan process problem:
Process (computing)
In computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system , a process may be made up of multiple threads of execution that execute instructions concurrently.A computer program is a...
whose parent process
Parent process
In computing, a parent process is a process that has created one or more child processes.- Unix :In the operating system Unix, every process except is created when another process executes the fork system call. The process that invoked fork is the parent process and the newly-created process is...
has finished or terminated
Exit (operating system)
On many computer operating systems, a computer process terminates its execution by making an exit system call. More generally, an exit in a multithreading environment means that a thread of execution has stopped running. The operating system reclaims resources that were used by the process...
, though itself remains running.
In a Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....
operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...
any orphaned process will be immediately adopted by the special init
Init
init is a program for Unix-based computer operating systems that spawns all other processes. It runs as a daemon and typically has PID 1. The boot loader starts the kernel and the kernel starts init...
system process. This operation is called re-parenting and occurs automatically. Even though technically the process has the "init" process as its parent, it is still called an orphan process since the process that originally created it no longer exists.
A process can be orphaned unintentionally, such as when the parent process terminates or crashes. The process group
Process group
In POSIX-conformant operating systems, a process group denotes a collection of one or more processes. Process groups are used to control the distribution of signals. A signal directed to a process group is delivered individually to all of the processes that are members of the group.Process groups...
mechanism in most Unix-like operation systems can be used to help protect against accidental orphaning, where in coordination with the user's shell
Unix shell
A Unix shell is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and for Unix-like systems...
will try to terminate all the child processes with the SIGHUP
SIGHUP
On POSIX-compliant platforms, SIGHUP is a signal sent to a process when its controlling terminal is closed....
process signal, rather than letting them continue to run as orphans.
A process may also be intentionally orphaned so that it becomes detached from the user's session and left running in the background; usually to allow a long-running job to complete without further user attention, or to start an indefinitely running service. Under Unix, the latter kinds of processes are typically called daemon processes
Daemon (computer software)
In Unix and other multitasking computer operating systems, a daemon is a computer program that runs as a background process, rather than being under the direct control of an interactive user...
. The Unix nohup
Nohup
nohup is a POSIX command to ignore the HUP signal, enabling the command to keep running after the user who issues the command has logged out. The HUP signal is by convention the way a terminal warns depending processes of logout....
command is one means to accomplish this.
With remote invocation, a server process is also said to be orphaned when the client that initiated the request unexpectedly crashes after making the request while leaving the server process running.
These orphaned processes waste server resources and can potentially leave a server starved for resources. However there are several solutions to the orphan process problem:
- Extermination is the most commonly used technique; in this case the orphan is killed.
- Reincarnation is a technique in which machines periodically try to locate the parents of any remote computations; at which point orphaned processes are killed.
- Expiration is a technique where each process is allotted a certain amount of time to finish before being killed. If need be a process may "ask" for more time to finish before the allotted time expires.
See also
- Zombie processZombie processOn Unix and Unix-like computer operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table. This entry is still needed to allow the process that started the process to read its exit status. The term zombie process...
- Daemon processDaemon (computer software)In Unix and other multitasking computer operating systems, a daemon is a computer program that runs as a background process, rather than being under the direct control of an interactive user...