mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 17:41:50 +00:00
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>
This commit is contained in:
parent
73c279927f
commit
49d769d52e
1 changed files with 8 additions and 8 deletions
|
@ -26,6 +26,7 @@
|
||||||
#include <linux/profile.h>
|
#include <linux/profile.h>
|
||||||
#include <linux/mount.h>
|
#include <linux/mount.h>
|
||||||
#include <linux/proc_fs.h>
|
#include <linux/proc_fs.h>
|
||||||
|
#include <linux/kthread.h>
|
||||||
#include <linux/mempolicy.h>
|
#include <linux/mempolicy.h>
|
||||||
#include <linux/taskstats_kern.h>
|
#include <linux/taskstats_kern.h>
|
||||||
#include <linux/delayacct.h>
|
#include <linux/delayacct.h>
|
||||||
|
@ -254,26 +255,25 @@ static int has_stopped_jobs(struct pid *pgrp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reparent_to_init - Reparent the calling kernel thread to the init task of the pid space that the thread belongs to.
|
* reparent_to_kthreadd - Reparent the calling kernel thread to kthreadd
|
||||||
*
|
*
|
||||||
* If a kernel thread is launched as a result of a system call, or if
|
* If a kernel thread is launched as a result of a system call, or if
|
||||||
* it ever exits, it should generally reparent itself to init so that
|
* it ever exits, it should generally reparent itself to kthreadd so it
|
||||||
* it is correctly cleaned up on exit.
|
* isn't in the way of other processes and is correctly cleaned up on exit.
|
||||||
*
|
*
|
||||||
* The various task state such as scheduling policy and priority may have
|
* The various task state such as scheduling policy and priority may have
|
||||||
* been inherited from a user process, so we reset them to sane values here.
|
* been inherited from a user process, so we reset them to sane values here.
|
||||||
*
|
*
|
||||||
* NOTE that reparent_to_init() gives the caller full capabilities.
|
* NOTE that reparent_to_kthreadd() gives the caller full capabilities.
|
||||||
*/
|
*/
|
||||||
static void reparent_to_init(void)
|
static void reparent_to_kthreadd(void)
|
||||||
{
|
{
|
||||||
write_lock_irq(&tasklist_lock);
|
write_lock_irq(&tasklist_lock);
|
||||||
|
|
||||||
ptrace_unlink(current);
|
ptrace_unlink(current);
|
||||||
/* Reparent to init */
|
/* Reparent to init */
|
||||||
remove_parent(current);
|
remove_parent(current);
|
||||||
current->parent = child_reaper(current);
|
current->real_parent = current->parent = kthreadd_task;
|
||||||
current->real_parent = child_reaper(current);
|
|
||||||
add_parent(current);
|
add_parent(current);
|
||||||
|
|
||||||
/* Set the exit signal to SIGCHLD so we signal init on exit */
|
/* Set the exit signal to SIGCHLD so we signal init on exit */
|
||||||
|
@ -400,7 +400,7 @@ void daemonize(const char *name, ...)
|
||||||
current->files = init_task.files;
|
current->files = init_task.files;
|
||||||
atomic_inc(¤t->files->count);
|
atomic_inc(¤t->files->count);
|
||||||
|
|
||||||
reparent_to_init();
|
reparent_to_kthreadd();
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(daemonize);
|
EXPORT_SYMBOL(daemonize);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue