Having some difficulties with Linux kernel namespaces today, specifically correlating PIDs inside of a unique PID namespace to those within the global PID namespace
I need to be able to do one of the following:
a) Kill a process from the global scope using a PID assigned by the namespace
OR
b) Translate a namespace specific PID to a global PID, so I can kill the PID from the global scope
OR
c) Enable a process within a PID namespace to report to me its global PID, so I can kill the PID from the global scope
There is some discussion on the process structures which contain the PID information in namespace scenarios here. I'm not sure how / if I can access these structures from a userland application, or if I need to add in support via a kernel hack.
Why? I have an application which currently uses network namespaces. I am adding support for PID namespaces. Here is how it currently works:
Before the introduction of PID namespaces: The main application currently launches a bash console in another network namespace. It then uses that bash console to start programs and has those programs report their current PID. When the main application wants to kill a subprocess in that network namespace, it just tells the OS to kill the PID reported back.
With PID namespaces (broken state): The main application currently launches a bash console in another network and PID namespace. It then uses that bash console to start programs and has those programs report their current PID. However, the current PID reported back is not valid in the global PID namespace (it may be 10, when the PID in the global namespace is 56000). As a result, the main application cannot kill the subprocess in that network + PID namespace
As always, any guidance is appreciated