[CRIU] [PATCH 18/21] fork: Delete pid argument of set_pid_for_children_ns()

Kirill Tkhai ktkhai at virtuozzo.com
Tue May 23 05:41:07 PDT 2017


In next patches set_pid_for_children_ns() will be used
without pid, so move pid check out of function.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/cr-restore.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 10403eb3a..adeaeff5a 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -427,16 +427,13 @@ static void wait_pid_ns_helper_prepared(struct ns_id *pid_ns, struct pid *pid)
 	futex_wait_while_eq(&pid_ns->pid.helper_created, 0);
 }
 
-static int set_pid_ns_for_children(struct ns_id *pid_ns, struct pid *pid)
+static int set_pid_for_children_ns(struct ns_id *pid_ns)
 {
 	int fd, ret = 0;
 
 	if (!(root_ns_mask & CLONE_NEWPID))
 		return 0;
 
-	if (last_level_pid(pid) == INIT_PID)
-		return 0;
-
 	BUG_ON(!current);
 
 	if (current->pid_for_children_ns == pid_ns)
@@ -477,7 +474,8 @@ static int setup_child_task_namespaces(struct pstree_item *item, struct ns_id **
 
 	wait_pid_ns_helper_prepared(pid_ns, item->pid);
 
-	if (set_pid_ns_for_children(pid_ns, item->pid) < 0)
+	if (last_level_pid(item->pid) != INIT_PID &&
+	    set_pid_for_children_ns(pid_ns) < 0)
 		return -1;
 
 	*ret_pid_ns = pid_ns;



More information about the CRIU mailing list