]> git.ipfire.org Git - thirdparty/util-linux.git/commit
nsenter: add option `-c` to join the cgroup of target process
authoru2386 <hugo.cavan2386@gmail.com>
Sun, 11 Jun 2023 16:16:57 +0000 (16:16 +0000)
committeru2386 <hugo.cavan2386@gmail.com>
Wed, 28 Jun 2023 15:48:14 +0000 (15:48 +0000)
commitb40650b71a742c188d0986a1162a5730ecb95510
tree0cabf5df38ac6696db7e1d817ab4977bba516fcd
parent2b48beb44ebdf18c7784d06ebc77b50200125521
nsenter: add option `-c` to join the cgroup of target process

This commit adds support for the -c or --join-cgroup option in nsenter, allowing a new process to join the cgroup of target process.

Example:
    Setup the target process:
        $ podman run --rm -d docker.io/golang sleep 10000
        51a89deb6baf6d
        $ podman inspect --format '{{ .State.Pid }}' 51a89deb6baf6d6
        216054

    Enter the cgroup namespace of target process without option -c:
        $ sudo ./nsenter -C -U -t 216054 sh -c "cat /proc/self/cgroup"
        0::/../../../../session-899.scope

    Enter the cgroup namespace of target process with option -c:
        $ sudo ./nsenter -c -C -U -t 216054 sh -c "cat /proc/self/cgroup"
        0::/

Reviewed-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de>
Signed-off-by: u2386 <hugo.cavan2386@gmail.com>
bash-completion/nsenter
include/pathnames.h
sys-utils/nsenter.1.adoc
sys-utils/nsenter.c