Commit 062f4688 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

pstree: Define symbolic name for init process

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent e2912397
...@@ -549,7 +549,7 @@ static inline int fork_with_pid(struct pstree_item *item, unsigned long ns_clone ...@@ -549,7 +549,7 @@ static inline int fork_with_pid(struct pstree_item *item, unsigned long ns_clone
goto err_unlock; goto err_unlock;
} else { } else {
ca.fd = -1; ca.fd = -1;
BUG_ON(pid != 1); BUG_ON(pid != INIT_PID);
} }
if (ca.clone_flags & CLONE_NEWNET) if (ca.clone_flags & CLONE_NEWNET)
...@@ -671,7 +671,7 @@ static void restore_sid(void) ...@@ -671,7 +671,7 @@ static void restore_sid(void)
sid = getsid(getpid()); sid = getsid(getpid());
if (sid != current->sid) { if (sid != current->sid) {
/* Skip the root task if it's not init */ /* Skip the root task if it's not init */
if (current == root_item && root_item->pid.virt != 1) if (current == root_item && root_item->pid.virt != INIT_PID)
return; return;
pr_err("Requested sid %d doesn't match inherited %d\n", pr_err("Requested sid %d doesn't match inherited %d\n",
current->sid, sid); current->sid, sid);
...@@ -855,7 +855,7 @@ static int restore_root_task(struct pstree_item *init, struct cr_options *opts) ...@@ -855,7 +855,7 @@ static int restore_root_task(struct pstree_item *init, struct cr_options *opts)
* this later. * this later.
*/ */
if (init->pid.virt == 1) { if (init->pid.virt == INIT_PID) {
if (!(opts->namespaces_flags & CLONE_NEWPID)) { if (!(opts->namespaces_flags & CLONE_NEWPID)) {
pr_err("This process tree can be restored in a new pid namespace.\n"); pr_err("This process tree can be restored in a new pid namespace.\n");
pr_err("crtools should be re-executed with --namespace pid\n"); pr_err("crtools should be re-executed with --namespace pid\n");
......
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
#include "list.h" #include "list.h"
#include "crtools.h" #include "crtools.h"
/*
* That's the init process which usually inherit
* all orphaned children in the system.
*/
#define INIT_PID (1)
struct pid { struct pid {
/* /*
* The @real pid is used to fetch tasks during dumping stage, * The @real pid is used to fetch tasks during dumping stage,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment