From 9ce88b829f66de041ff7f06150c79390ed977f69 Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Tue, 14 Apr 2015 13:55:04 +0800 Subject: [PATCH] add comments for nsexec.c It would be easier for people to understand how nsexec really works. Signed-off-by: Qiang Huang --- nsenter/nsexec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nsenter/nsexec.c b/nsenter/nsexec.c index 2db051d1..d8e45f3c 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");