Dear Maintainer,
The prctl manual page says:
PR_SET_CHILD_SUBREAPER (since Linux 3.4)
[…]
A subreaper fulfills the role of init(1) for its descendant pro‐
cesses. When a process becomes orphaned (i.e., its immediate
parent terminates), then that process will be reparented to the
nearest still living ancestor subreaper. […]
Part of the role of init(1) is to remain running while any child process
needs to be running: the kernel will panic if the global init goes away,
and will send SIGKILL to all processes of the namespace whose init dies.
The reference to a "still living" subreaper, however, suggests that this
does not apply to subreapers, and a test program confirms it; therefore,
subreapers do not fulfill the full role of init(1). That's overly vague
anyway; "man 1 init" references many things a subreaper wouldn't have to
do, and POSIX has only a few passing references to init or PID 1.
Also, the text contradicts pid_namespaces(7), which says:
When a child process becomes orphaned, it is reparented to the "init"
process in the PID namespace of its parent (unless one of the nearer
ancestors of the parent employed the prctl(2) PR_SET_CHILD_SUBREAPER
command […]
A process that dies in a PID namespace could be reparented to its PID 1,
even if "the nearest still living ancestor subreaper" is another process
outside the namespace.
- Michael