diff --git a/nsenter/nsexec.c b/nsenter/nsexec.c index 2db051d14..d8e45f3cd 100644 --- a/nsenter/nsexec.c +++ b/nsenter/nsexec.c @@ -137,6 +137,8 @@ void nsexec() } if (setjmp(env) == 1) { + // Child + if (setsid() == -1) { pr_perror("setsid failed"); exit(1); @@ -162,7 +164,11 @@ void nsexec() // Finish executing, let the Go runtime take over. return; } + // Parent + // We must fork to actually enter the PID namespace, use CLONE_PARENT + // so the child can have the right parent, and we don't need to forward + // the child's exit code or resend its death signal. child = clone_parent(&env); if (child < 0) { pr_perror("Unable to fork");