HOME

TheInfoList



OR:

An orphan process is a
computer process In computing, a process is the instance of a computer program that is being executed by one or many threads. There are many different process models, some of which are light weight, but almost all processes (even entire virtual machines) are ro ...
whose
parent process In computing, a parent process is a process that has created one or more child processes. Unix-like systems In Unix-like operating systems, every process except (the swapper) is created when another process executes the fork() system call. T ...
has finished or terminated, though it remains running itself.


Unix-like

In a
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 ...
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also i ...
any orphaned process will be immediately adopted by an implementation-defined system process: the kernel sets the parent to this process. This operation is called ''re-parenting'' and occurs automatically. Even though technically the process has a system process as its parent, it is still called an orphan process since the process that originally created it no longer exists. In other systems orphaned processes are immediately terminated by the kernel. Most Unix systems have historically used ''init'' as the system process to which orphans are reparented, but in modern
DragonFly BSD DragonFly BSD is a free and open-source Unix-like operating system forked from FreeBSD 4.8. Matthew Dillon, an Amiga developer in the late 1980s and early 1990s and FreeBSD developer between 1994 and 2003, began working on DragonFly BSD in ...
, FreeBSD, and Linux systems, an orphan process may be reparented to a "subreaper" process instead of ''init''. A process can be orphaned unintentionally, such as when the parent process terminates or crashes. The
process group In a POSIX-conformant operating system, a process group denotes a collection of one or more processes. Among other things, a process group is used to control the distribution of a signal; when a signal is directed to a process group, the signal is ...
mechanism in most Unix-like operating systems can be used to help protect against accidental orphaning, where in coordination with the user's
shell Shell may refer to: Architecture and design * Shell (structure), a thin structure ** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses ** Thin-shell structure Science Biology * Seashell, a hard o ...
will try to terminate all the child processes with the "hangup" signal (
SIGHUP On POSIX-compliant platforms, SIGHUP ("signal hang up") is a signal sent to a process when its controlling terminal is closed. It was originally designed to notify the process of a serial line drop. SIGHUP is a symbolic constant defined in the h ...
), rather than letting them continue to run as orphans. More precisely, as part of job control, when the shell exits, because it is the "session leader" (its session id equals its process id), the corresponding
login session In computing, a login session is the period of activity between a user logging in and logging out of a (multi-user) system. On Unix and Unix-like operating systems, a login session takes one of two main forms: * When a textual user interface i ...
ends, and the shell sends SIGHUP to all its jobs (internal representation of process groups). It is sometimes desirable to intentionally orphan a process, usually to allow a long-running job to complete without further user attention, or to start an indefinitely running service or agent; such processes (without an associated session) are known as
daemon Daimon or Daemon (Ancient Greek: , "god", "godlike", "power", "fate") originally referred to a lesser deity or guiding spirit such as the daimons of ancient Greek religion and Greek mythology, mythology and of later Hellenistic religion and Hell ...
s, particularly if they are indefinitely running. A low-level approach is to
fork In cutlery or kitchenware, a fork (from la, furca 'pitchfork') is a utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tine (structural), tines with which one ...
twice, running the desired process in the grandchild, and immediately terminating the child. The grandchild process is now orphaned, and is not adopted by its grandparent, but rather by init. Higher-level alternatives circumvent the shell's hangup handling, either telling the child process to ignore SIGHUP (by using
nohup nohup is a POSIX command which means "no hang up". Its purpose is to execute a command such that it ignores the HUP (hangup) signal and therefore does not stop when the user logs out. Output that would normally go to the terminal goes to a file ...
), or removing the job from the job table or telling the shell to not send SIGHUP on session end (by using
disown Disownment occurs when a parent renounces or no longer accepts a child as a family member, usually due to reprehensible actions leading to serious emotional consequences. Different from giving a child up for adoption, it is a social and interpers ...
in either case). In any event, the session id (process id of the session leader, the shell) does not change, and the process id of the session that has ended is still in use until all orphaned processes either terminate or change session id (by starting a new session via setsid(2)). To simplify system administration, it is often desirable to use a service wrapper so that processes not designed to be used as services respond correctly to system signals. An alternative to keep processes running without orphaning them is to use a
terminal multiplexer A terminal multiplexer is a software application that can be used to multiplex several separate pseudoterminal-based login sessions inside a single terminal display, terminal emulator window, PC/workstation system console, or remote login session ...
and run the processes in a detached session (or a session that becomes detached), so the session is not terminated and the process is not orphaned. 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: # Termination 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 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". ...
* Daemon process


References

*
10.6.4 Orphaned Process Groups
, ''The Process Model of Linux Application Development'', by Erik W. Troan and Michael K. Johnson, Jul 8, 2005 Definition : An orphan process is running process whose parent process is terminated or finished. {{DEFAULTSORT:Orphan Process Process (computing)