# Process identity and namespaces [Русский](Process-identity-ru.md) · [Wiki home](Home.md) A PID is meaningful in a particular PID namespace. A shell inside a managed instance and a monitoring tool on the host see different numbers for the same process. Recreating the shell on another machine gives it a new kernel task. arch-m2m can still preserve the numbers visible to Bash, its children and tmux. For example, a foreground job reference in Bash must resolve to the child that will actually exit. ```text host view instance PID view source Bash PID A PID S source nano PID B, parent A PID J, parent S restored Bash PID C PID S restored nano PID D, parent C PID J, parent S ``` The letters stand for example identifiers. Matching the two copies of S alone proves very little. The restored shell must have the right parent, job, session and terminal relationships in its own namespace. [Linux PID namespaces](https://man7.org/linux/man-pages/man7/pid_namespaces.7.html) ## Creating the target 1. The semantic constructor calls `unshare()` to prepare private PID, mount and time namespaces. The first child in the new PID namespace becomes PID 1 and acts as supervisor. A private procfs mount exposes that namespace's view of the tree. 2. The constructor uses `clone3()` with `set_tid` to select the saved inner PID for the tmux server. It also coordinates child creation while constructing the panes. Linux must be able to allocate each requested PID in the target namespace. 3. A private devpts mount gives the instance its own PTY numbering. Bind mounts expose private home and temporary directories at the paths the programs expect. Programs and libraries run from the target Arch userspace. 4. The constructor sets time namespace offsets for `CLOCK_MONOTONIC` and `CLOCK_BOOTTIME`. These preserve the application's clock reference across hosts. Wall-clock time still follows the host. The semantic host provider shares the host network. Namespaces give the restored applications their required view of selected resources. Project directories and remote services still require separate coordination. [clone(2)](https://man7.org/linux/man-pages/man2/clone.2.html) · [time_namespaces(7)](https://man7.org/linux/man-pages/man7/time_namespaces.7.html) ## Checking which process is alive The controller opens a pidfd with `pidfd_open()`. Once the task exits, the descriptor becomes readable even if the kernel later assigns its old numeric PID to a different task. The ownership check also uses the boot ID, process start time, namespace identities, process root, executable hash and application cgroup. A mismatch stops the operation. A metadata directory can survive a reboot long after the task it described has disappeared. [pidfd_open(2)](https://man7.org/linux/man-pages/man2/pidfd_open.2.html) Next: [Taking a consistent snapshot](Consistent-capture.md).