Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In UNIX, when a parent process disappears, I thought that all child processes reset init as their parent. Is this not correct all the time? Are there any exceptions?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Moving my comment to an answer.... I don't believe there are exceptions.

Found this "sometimes the parent process is killed before its child is killed. In this case, the "parent of all processes," init process, becomes the new PPID (parent process ID). Sometime these processes are called orphan process." source

Similarly is described in IBM's blog: "The parent dies or gets killed before the child. In the above scenario, the child process becomes the orphan process (as it has lost its parent). In Linux, the init process comes to the rescue of the orphan processes and adopts them. This means after a chile has lost its parent, the init process becomes its new parent process."

share|improve this answer

According to the exit man page from The Single UNIX® Specification, Version 2:

The parent process ID of all of the calling process' existing child processes and zombie processes is set to the process ID of an implementation-dependent system process. That is, these processes are inherited by a special system process.

For most Unix variants, that special process is init (PID 1).

The Linux wait(2) man page confirms this:

If a parent process terminates, then its "zombie" children (if any) are adopted by init(8), which automatically performs a wait to remove the zombies.

The FreeBSD wait(2), NetBSD wait(2), OpenBSD wait(2) and Mac OS X wait(2) man pages confirm this too:

If a parent process terminates without waiting for all of its child processes to terminate, the remaining child processes are assigned the parent process 1 ID (the init process ID).

The Oracle Solaris 11.1 wait(3C) man page confirms this too:

If a parent process terminates without waiting for its child processes to terminate, the parent process ID of each child process is set to 1, with the initialization process inheriting the child processes; see Intro(2).

share|improve this answer

I don't believe so. It always goes to the init process.

http://en.wikipedia.org/wiki/Orphan_process

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.