Documentation ¶
Overview ¶
Package pidmap translates process PIDs (and also task TIDs) between different PID namespaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NSpid ¶
NSpid returns the list of namespaced PIDs for the process or task with the specified PID (or TID). The returned information basically comes from the /proc filesystem, and the "NSpid:" status field in particular. NSpid only returns the list of PIDs, but not the corresponding PID namespaces; this is because the Linux kernel doesn't give us the namespace information as part of the process (task) status. Instead, a caller (such as NewPIDMap) needs to combine a namespaced PIDs list with the hierarchy of PID namespaces to calculate the correct namespacing.
Types ¶
type PIDMap ¶
type PIDMap map[model.NamespacedPID]model.NamespacedPIDs
PIDMap implements PIDMapper for translating PIDs (and also task TIDs) between PID namespaces.
func NewPIDMap ¶
func NewPIDMap(processes model.ProcessTable) PIDMap
NewPIDMap returns a new PID map based on the specified PID table and further information gathered from the /proc filesystem. If the process table was discovered including tasks, then these tasks will be mapped too, similar to what the Linux procfs does using the TIDs as PIDs.
func (PIDMap) NamespacedPIDs ¶
NamespacedPIDs returns for a specific namespaced PID the list of all PIDs the corresponding process has been given in different PID namespaces. Returns nil if the PID doesn't exist in the specified PID namespace. The list is ordered from the topmost PID namespace down to the leaf PID namespace to which a process actually is joined to.
func (PIDMap) Translate ¶
func (pidmap PIDMap) Translate(pid model.PIDType, from model.Namespace, to model.Namespace) model.PIDType
Translate translates a PID "pid" in PID namespace "from" to the corresponding PID in PID namespace "to". Returns 0, if PID "pid" either does not exist in namespace "from", or PID namespace "to" isn't either a parent or child of PID namespace "from".
If the PIDMap has been created using a model.ProcessTable that includes tasks, then additionally task TIDs can be mapped by simply specifying a TID in place of a PID.