Provided by: manpages-dev_4. The fd argument is a file descriptor referring to one of the namespace entries in a /proc/[pid]/ns/ directory; see namespaces(7) for further informationCGROUP (since Linux 4.6) fd must refer to a cgroup namespace..) If fd refers to a PID namespaces, the semantics are somewhat different from other namespace types: reassociating the calling thread with a PID namespace changes only the PID namespace that subsequently created child processes of the caller will be placed in; it does not change the PID namespace of the caller itself. Reassociating with a PID namespace is allowed only if the PID namespace specified by fd is a descendant (child, grandchild, etc.) of the PID namespace of the caller. For further details on PID namespaces, see pid_namespaces(7). A process reassociating itself with a user namespace must have the CAP_SYS_ADMIN capability in the target user namespace. Upon successfully joining a user namespace, a process is granted all capabilities in that namespace, regardless of its user and group IDs. A multithreaded process may not change user namespace with setns(). It is not permitted to use setns() to reenter the caller's current user namespace. This prevents a caller that has dropped capabilities from regaining those capabilities via a call to setns(). For security reasons, a process can't join a new user namespace if it is sharing filesystem-related attributes (the attributes whose sharing is controlled by the clone(2) CLONE_FS flag) with another process. For further. Using setns() to change the caller's cgroup namespace does not change the caller's cgroup memberships.
RETURN VALUE
On success, setns() returns 0. On failure, -1 is returned and errno is set to indicate the error.
ERRORS
EBADF fd is not a valid file descriptor. EINVAL fd refers to a namespace whose type does not match that specified in nstype. EINVAL There is problem with reassociating the thread with the specified namespace. ENOMEM Cannot allocate sufficient memory to change the specified namespace. created (compiled as a binary named ns_exec) in conjunction with the CLONE_NEWUTS example program in the clone(2) man page (complied as a binary named newuts). We begin by executing the example program in clone(2) in the background..16 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at.