Test
// 子进程在新的 PID Namespace 中运行
static int child_func(void *arg) {
// 当前进程在容器内是 PID 1
mount("proc", "/proc", "proc", 0, NULL);
printf("Container PID: %d\n", getpid()); // 输出 1
execve("/bin/sh", ...);
}
// 宿主机上观察
$ cat /proc/5678/status | grep NSpid
NSpid: 5678 1
发表评论 取消回复