[CRIU] [PATCH 05/14] restore: Always set real pid in restore_task_with_children()

Kirill Tkhai ktkhai at virtuozzo.com
Mon May 15 06:05:17 PDT 2017


In next patches, root_item will need to have its real pid
to be sure, usernsd already sees it.

Also add a comment, explaning why set real pid in two places.

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

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index ccee39ebf..f516ab0d4 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1265,8 +1265,8 @@ static int do_fork_with_pid(struct pstree_item *item, struct ns_id *pid_ns, stru
 			close_pid_proc();
 		pid = clone_noasan(restore_task_with_children, ca->clone_flags | SIGCHLD, ca);
 		if (item == root_item) {
+			/* We want to use it before it's set in restore_task_with_children() */
 			item->pid->real = pid;
-			pr_debug("PID: real %d virt %d\n", pid, vpid(item));
 		}
 		return pid > 0 ? 0 : -1;
 	}
@@ -1689,13 +1689,10 @@ static int restore_task_with_children(void *_arg)
 
 	current = ca->item;
 
-	if (current != root_item) {
-		current->pid->real = get_self_real_pid();
-		pr_debug("PID: real %d virt %d\n",
-				current->pid->real, vpid(current));
-		if (current->pid->real < 0)
-			goto err;
-	}
+	current->pid->real = get_self_real_pid();
+	pr_debug("PID: real %d virt %d\n", current->pid->real, vpid(current));
+	if (current->pid->real < 0)
+		goto err;
 
 	if ( !(ca->clone_flags & CLONE_FILES))
 		close_safe(&ca->fd);



More information about the CRIU mailing list