]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
pid: remove the child_reaper special case in init/main.c
authorEric W. Biederman <ebiederm@xmission.com>
Wed, 23 Mar 2011 23:43:12 +0000 (16:43 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 24 Mar 2011 02:46:57 +0000 (19:46 -0700)
This patchset is a cleanup and a preparation to unshare the pid namespace.
These prerequisites prepare for Eric's patchset to give a file descriptor
to a namespace and join an existing namespace.

This patch:

It turns out that the existing assignment in copy_process of the
child_reaper can handle the initial assignment of child_reaper we just
need to generalize the test in kernel/fork.c

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: Serge E. Hallyn <serge@hallyn.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/pid.h
init/main.c
kernel/fork.c

index 49f1c2f66e951bc7e226a5809450af8714c80473..efceda0a51b137b3c154488a5f6d90385be064ba 100644 (file)
@@ -140,6 +140,17 @@ static inline struct pid_namespace *ns_of_pid(struct pid *pid)
        return ns;
 }
 
+/*
+ * is_child_reaper returns true if the pid is the init process
+ * of the current namespace. As this one could be checked before
+ * pid_ns->child_reaper is assigned in copy_process, we check
+ * with the pid number.
+ */
+static inline bool is_child_reaper(struct pid *pid)
+{
+       return pid->numbers[pid->level].nr == 1;
+}
+
 /*
  * the helpers to get the pid's id seen from different namespaces
  *
index 3627bb37225c77552b83a8c9f6babc12bee2df2e..4a9479ef4540df99586d5e0b3854c2b3c46d91c4 100644 (file)
@@ -787,15 +787,6 @@ static int __init kernel_init(void * unused)
         * init can run on any cpu.
         */
        set_cpus_allowed_ptr(current, cpu_all_mask);
-       /*
-        * Tell the world that we're going to be the grim
-        * reaper of innocent orphaned children.
-        *
-        * We don't want people to have to make incorrect
-        * assumptions about where in the task array this
-        * can be found.
-        */
-       init_pid_ns.child_reaper = current;
 
        cad_pid = task_pid(current);
 
index f2b494d7c55735e1b74e46f371cd1d2101caa39c..17aed4378eda7a8fcb1fbeb5a79538f01a165552 100644 (file)
@@ -1296,7 +1296,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
                tracehook_finish_clone(p, clone_flags, trace);
 
                if (thread_group_leader(p)) {
-                       if (clone_flags & CLONE_NEWPID)
+                       if (is_child_reaper(pid))
                                p->nsproxy->pid_ns->child_reaper = p;
 
                        p->signal->leader_pid = pid;