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?
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,"
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
Three answers written in 2014, all saying that in Unices and in Linux the process is reparented to process #1 without exception. Three wrong answers. ☺
As the SUS says, quoted in one of the other answers here so I won't quote it again, the parent process of orphaned children is set to an implementation-defined process. Cristian Ciupitu is right to consult the Linux doco to see what the implementation defines. But xe is being misled by that doco, which is inconsistent and not up-to-date.
Two years before these three answers were written, and fast coming up to three years ago at the time of first writing this answer, the Linux kernel changed. The systemd developers added the ability for processes to set themselves up as "subreapers". From Linux 3.4 onwards processes can issue the
In version 10.2, FreeBSD gained the same ability, extending its existing
So there are exceptions, and fairly prominent ones: On Linux, FreeBSD/PC-BSD, and DragonFly BSD, the parent process of orphaned children is set to the nearest grandparent process of the child that is marked as a subreaper, or process #1 if there is no grandparent subreaper process. Various dæmon supervision utilities — including systemd (the one whose developers put this into the Linux kernel in the first place), upstart, and the nosh
If such a dæmon supervisor is not process #1, and it spawns a service such as an interactive login session, and in that session one does the (quite wrongheaded) trick of attempting to "dæmonize" by double-
According to the
For most Unix variants, that special process is
The Oracle Solaris 11.1
I don't believe so. It always goes to the init process.