Move some random stuff which doesn't need tasklist_lock from reparent_to_init()
to its caller, daemonize(). Strictly speaking, rlim is protected by task_lock()
but we don't need it to copy init_task->rlim.

Signed-off-by: Oleg Nesterov <[EMAIL PROTECTED]>

--- 2.6.21-rc5/kernel/exit.c~1_REDUCE   2007-04-05 12:18:28.000000000 +0400
+++ 2.6.21-rc5/kernel/exit.c    2007-04-10 21:32:44.000000000 +0400
@@ -271,7 +271,6 @@ static void reparent_to_init(void)
        write_lock_irq(&tasklist_lock);
 
        ptrace_unlink(current);
-       /* Reparent to init */
        remove_parent(current);
        current->parent = child_reaper(current);
        current->real_parent = child_reaper(current);
@@ -280,17 +279,8 @@ static void reparent_to_init(void)
        /* Set the exit signal to SIGCHLD so we signal init on exit */
        current->exit_signal = SIGCHLD;
 
-       if (!has_rt_policy(current) && (task_nice(current) < 0))
-               set_user_nice(current, 0);
-       /* cpus_allowed? */
-       /* rt_priority? */
-       /* signals? */
        security_task_reparent_to_init(current);
-       memcpy(current->signal->rlim, init_task.signal->rlim,
-              sizeof(current->signal->rlim));
-       atomic_inc(&(INIT_USER->__count));
        write_unlock_irq(&tasklist_lock);
-       switch_uid(INIT_USER);
 }
 
 void __set_special_pids(pid_t session, pid_t pgrp)
@@ -402,6 +392,17 @@ void daemonize(const char *name, ...)
        atomic_inc(&current->files->count);
 
        reparent_to_init();
+
+       if (!has_rt_policy(current) && (task_nice(current) < 0))
+               set_user_nice(current, 0);
+       /* cpus_allowed? */
+       /* rt_priority? */
+       /* signals? */
+       memcpy(current->signal->rlim, init_task.signal->rlim,
+              sizeof(current->signal->rlim));
+
+       atomic_inc(&(INIT_USER->__count));
+       switch_uid(INIT_USER);
 }
 
 EXPORT_SYMBOL(daemonize);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to