2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00

restore: create pid namespace

A pid namespace is created if a pid of the first task is 1.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin
2012-06-19 15:53:00 +04:00
committed by Pavel Emelyanov
parent 83e6d14efd
commit c8e6be95e4

View File

@@ -521,11 +521,20 @@ static inline int fork_with_pid(struct pstree_item *item, unsigned long ns_clone
goto err_close;
}
/* A process with pid = 1 is "init". It should be restore in new pid ns.
* The first process in pid ns gets pid = 1 automaticaly. */
if (pid == 1) {
ca.clone_flags |= CLONE_NEWPID;
if (item != root_item) {
pr_err("Only first task can have pid = 1");
goto err_unlock;
}
} else
if (write_img_buf(ca.fd, buf, strlen(buf)))
goto err_unlock;
ret = clone(restore_task_with_children, stack + STACK_SIZE,
ns_clone_flags | SIGCHLD, &ca);
ca.clone_flags | SIGCHLD, &ca);
if (ret < 0)
pr_perror("Can't fork for %d", pid);