$linuxjunkies
>

PID namespace

also: process namespace

A Linux kernel feature that isolates process ID numbering, allowing different groups of processes to have their own independent PID sequences. Processes in different namespaces can have the same PID without conflict.

A PID namespace is a kernel isolation mechanism that virtualizes process identifiers. Each namespace maintains its own independent set of PIDs, allowing multiple processes across different namespaces to use the same PID number without collision.

PID namespaces form a hierarchy: a parent namespace can see and manage all processes in child namespaces, but processes in child namespaces cannot see processes outside their own namespace. This is essential for containers, which need their own init process (PID 1) isolated from the host system.

For example, a Docker container gets its own PID namespace where its main application appears as PID 1, while the host sees the same process with a different PID (e.g., 4521). The container cannot access or signal processes outside its namespace, providing strong process isolation.

PID namespaces are created using clone() or unshare() system calls with the CLONE_NEWPID flag, and are commonly used alongside other namespace types (mount, network, IPC) to create containerized environments.

Related terms