Eric et al,
Eventually, there will be more namespace man pages, but let us start
now with one for PID namespaces. The attached page aims to provide a
fairly complete overview of PID namespaces.
PID_NAMESPACES(7) Linux Programmer's Manual PID_NAMESPACES(7)
NAME
pid_namespaces - overview of Linux PID namespaces
DESCRIPTION
For an overview of namespaces, see namespaces(7).
PID namespaces isolate the process ID number space, meaning
that processes in different PID namespaces can have the same
PID.
PID namespaces allow containers to migrate to a new host
while the processes inside the container maintain the same
PIDs.
Likewise, a process in an ancestor namespace canâsubject to the
usual permission checks described in kill(2)âsend signals to
the "init" process of a child PID namespace only if the "init"
process has established a handler for that signal. (Within the
handler, the siginfo_t si_pid field described in sigaction(2)
will be zero.) SIGKILL or SIGSTOP are treated exceptionally:
these signals are forcibly delivered when sent from an ancestor
PID namespace. Neither of these signals can be caught by the
"init" process, and so will result in the usual actions associâ
ated with those signals (respectively, terminating and stopping
the process).
To put things another way: a process's PID namespace membership
is determined when the process is created and cannot be changed
thereafter. Among other things, this means that the parental
relationship between processes mirrors the parental between PID
namespaces: the parent of a process is either in the same
namespace or resides in the immediate parent PID namespace.
Every thread in a process must be in the same PID namespace.
For this reason, the two following call sequences will fail:
unshare(CLONE_NEWPID);
clone(..., CLONE_VM, ...); /* Fails */
setns(fd, CLONE_NEWPID);
clone(..., CLONE_VM, ...); /* Fails */
Because the above unshare(2) and setns(2) calls only change the
PID namespace for created children, the clone(2) calls necesâ
sarily put the new thread in a different PID namespace from the
calling thread.
Miscellaneous
After creating a new PID namespace, it is useful for the child
to change its root directory and mount a new procfs instance at
/proc so that tools such as ps(1) work correctly. (If a new
mount namespace is simultaneously created by including
CLONE_NEWNS in the flags argument of clone(2) or unshare(2)),
then it isn't necessary to change the root directory: a new
procfs instance can be mounted directly over /proc.)
Calling readlink(2) on the path /proc/self yields the process
ID of the caller in the PID namespace of the procfs mount
(i.e., the PID namespace of the process that mounted the
procfs).
When a process ID is passed over a UNIX domain socket to a
process in a different PID namespace (see the description of
SCM_CREDENTIALS in unix(7)), it is translated into the correâ
sponding PID value in the receiving process's PID namespace.
CONFORMING TO
Namespaces are a Linux-specific feature.