Originally posted by tobias
View Post
Process with the PID1 value can do things with process control that processes without this value cannot.
There is loophole but it turns into turtles all the way down.
You PID1 could start PID2 in a PID namespace with cgroups so that PID2 is a PID1 for all the processes in the cgroup tree it is.
Yes PID1 value it does not matter if you get this by PID Namespace or by being the host PID1 you get the process control power by having it. This is linked back to how cgroups were implemented.
Yes you terminate the PID1 of a PID namespace be it PID2 or PID1000.... that complete cgroup of that PID namespace is instant die.
By the way the Linux kernel runs a PID0 process and it the one that get really upset when it cannot find a PID1 todo tasks for it. Yes this is why when booting the pid1 started in initrd is able to be replaced by a different PID1 latter in the boot process.
sysvinit did not have proper service management. Solaris with it zones was designed with a PID2 that allowed higher process control that SMF(Solaris systemd like thing) runs as.
Remember PID1 is the one that cleans up the dead/zombie processes that can be holding file-handles and the like. This is one of the issues you don't want to attempt restart a process while a zombie of it prior run has to be cleaned up because now can be causing the new process you attempt to start to turn into a new zombie and repeat until you run out of processes and the system stops.
This is not as simple as lets just split what PID1 does into more than 1 process as to be able todo this would require kernel changes.
Interesting point is that the PID namespace thing shows it possible to have more than 1 PID1 just we cannot define a backup PID1 in host mode. Lets say we could start another copy of systemd as like PID2 tell the kernel if PID1 dies for any reason switch to PID2 and keep on working this would fix most of the reliability issue but this would require kernel changes. Remember you system booting already does change from PID1 in the initrd to PID1 from the root directory.
Comment