aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-05-09 05:34:33 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-09 15:30:53 -0400
commit49d769d52e16efabd3ad47b7995522fff771371d (patch)
treecf6ec2c39ae671c3f4cae34daf9d0558ca4fcf49 /kernel
parent73c279927f89561ecb45b2dfdf9314bafcfd9f67 (diff)
Change reparent_to_init to reparent_to_kthreadd
When a kernel thread calls daemonize, instead of reparenting the thread to init reparent the thread to kthreadd next to the threads created by kthread_create. This is really just a stop gap until daemonize goes away, but it does ensure no kernel threads are under init and they are all in one place that is easy to find. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Cc: Oleg Nesterov <oleg@tv-sign.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/exit.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index f5a7abb621f3..bc982cd72743 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -26,6 +26,7 @@
26#include <linux/profile.h> 26#include <linux/profile.h>
27#include <linux/mount.h> 27#include <linux/mount.h>
28#include <linux/proc_fs.h> 28#include <linux/proc_fs.h>
29#include <linux/kthread.h>
29#include <linux/mempolicy.h> 30#include <linux/mempolicy.h>
30#include <linux/taskstats_kern.h> 31#include <linux/taskstats_kern.h>
31#include <linux/delayacct.h> 32#include <linux/delayacct.h>
@@ -254,26 +255,25 @@ static int has_stopped_jobs(struct pid *pgrp)
254} 255}
255 256
256/** 257/**
257 * reparent_to_init - Reparent the calling kernel thread to the init task of the pid space that the thread belongs to. 258 * reparent_to_kthreadd - Reparent the calling kernel thread to kthreadd
258 * 259 *
259 * If a kernel thread is launched as a result of a system call, or if 260 * If a kernel thread is launched as a result of a system call, or if
260 * it ever exits, it should generally reparent itself to init so that 261 * it ever exits, it should generally reparent itself to kthreadd so it
261 * it is correctly cleaned up on exit. 262 * isn't in the way of other processes and is correctly cleaned up on exit.
262 * 263 *
263 * The various task state such as scheduling policy and priority may have 264 * The various task state such as scheduling policy and priority may have
264 * been inherited from a user process, so we reset them to sane values here. 265 * been inherited from a user process, so we reset them to sane values here.
265 * 266 *
266 * NOTE that reparent_to_init() gives the caller full capabilities. 267 * NOTE that reparent_to_kthreadd() gives the caller full capabilities.
267 */ 268 */
268static void reparent_to_init(void) 269static void reparent_to_kthreadd(void)
269{ 270{
270 write_lock_irq(&tasklist_lock); 271 write_lock_irq(&tasklist_lock);
271 272
272 ptrace_unlink(current); 273 ptrace_unlink(current);
273 /* Reparent to init */ 274 /* Reparent to init */
274 remove_parent(current); 275 remove_parent(current);
275 current->parent = child_reaper(current); 276 current->real_parent = current->parent = kthreadd_task;
276 current->real_parent = child_reaper(current);
277 add_parent(current); 277 add_parent(current);
278 278
279 /* Set the exit signal to SIGCHLD so we signal init on exit */ 279 /* Set the exit signal to SIGCHLD so we signal init on exit */
@@ -400,7 +400,7 @@ void daemonize(const char *name, ...)
400 current->files = init_task.files; 400 current->files = init_task.files;
401 atomic_inc(&current->files->count); 401 atomic_inc(&current->files->count);
402 402
403 reparent_to_init(); 403 reparent_to_kthreadd();
404} 404}
405 405
406EXPORT_SYMBOL(daemonize); 406EXPORT_SYMBOL(daemonize);