diff options
-rw-r--r-- | kernel/exit.c | 16 |
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 | */ |
268 | static void reparent_to_init(void) | 269 | static 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(¤t->files->count); | 401 | atomic_inc(¤t->files->count); |
402 | 402 | ||
403 | reparent_to_init(); | 403 | reparent_to_kthreadd(); |
404 | } | 404 | } |
405 | 405 | ||
406 | EXPORT_SYMBOL(daemonize); | 406 | EXPORT_SYMBOL(daemonize); |