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>