[v2,18/21] fork: Delete pid argument of set_pid_for_children_ns()

Submitted by Kirill Tkhai on May 31, 2017, 5:54 p.m.

Details

Message ID 149625328297.18060.9476543244014992872.stgit@localhost.localdomain
State Accepted
Series "Add /proc/[pid]/ns/pid_for_children ns support (and fixes)"
Headers show

Commit Message

Kirill Tkhai May 31, 2017, 5:54 p.m.
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@virtuozzo.com>
---
 criu/cr-restore.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 70d369ada..48b718695 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;