Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b2b2cbc4b2a2f389442549399a993a8306420baf
Commit:     b2b2cbc4b2a2f389442549399a993a8306420baf
Parent:     ef129412b4cbd6686d0749612cb9b76e207271f4
Author:     Eric W. Biederman <[EMAIL PROTECTED]>
AuthorDate: Thu Dec 21 21:28:40 2006 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Fri Dec 22 09:03:41 2006 -0800

    [PATCH] Fix reparenting to the same thread group. (take 2)
    
    This patch fixes the case when we reparent to a different thread in the
    same thread group.  This modifies the code so that we do not send
    signals and do not change the signal to send to SIGCHLD unless we have
    change the thread group of our parents.  It also suppresses sending
    pdeath_sig in this cas as well since the result of geppid doesn't
    change.
    
    Thanks to Oleg for spotting my bug of only fixing this for non-ptraced
    tasks.
    
    Signed-off-by: Eric W. Biederman <[EMAIL PROTECTED]>
    Cc: Mike Galbraith <[EMAIL PROTECTED]>
    Cc: Albert Cahalan <[EMAIL PROTECTED]>
    Cc: Andrew Morton <[EMAIL PROTECTED]>
    Cc: Roland McGrath <[EMAIL PROTECTED]>
    Cc: Ingo Molnar <[EMAIL PROTECTED]>
    Cc: Coywolf Qi Hunt <[EMAIL PROTECTED]>
    Acked-by: Oleg Nesterov <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 kernel/exit.c |   37 ++++++++++++++++++++++---------------
 1 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 85917c2..46cf6b6 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -597,14 +597,6 @@ choose_new_parent(struct task_struct *p, struct 
task_struct *reaper)
 static void
 reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
 {
-       /* We don't want people slaying init.  */
-       if (p->exit_signal != -1)
-               p->exit_signal = SIGCHLD;
-
-       if (p->pdeath_signal)
-               /* We already hold the tasklist_lock here.  */
-               group_send_sig_info(p->pdeath_signal, SEND_SIG_NOINFO, p);
-
        /* Move the child from its dying parent to the new one.  */
        if (unlikely(traced)) {
                /* Preserve ptrace links if someone else is tracing this child. 
 */
@@ -620,13 +612,7 @@ reparent_thread(struct task_struct *p, struct task_struct 
*father, int traced)
                p->parent = p->real_parent;
                add_parent(p);
 
-               /* If we'd notified the old parent about this child's death,
-                * also notify the new parent.
-                */
-               if (p->exit_state == EXIT_ZOMBIE && p->exit_signal != -1 &&
-                   thread_group_empty(p))
-                       do_notify_parent(p, p->exit_signal);
-               else if (p->state == TASK_TRACED) {
+               if (p->state == TASK_TRACED) {
                        /*
                         * If it was at a trace stop, turn it into
                         * a normal stop since it's no longer being
@@ -636,6 +622,27 @@ reparent_thread(struct task_struct *p, struct task_struct 
*father, int traced)
                }
        }
 
+       /* If this is a threaded reparent there is no need to
+        * notify anyone anything has happened.
+        */
+       if (p->real_parent->group_leader == father->group_leader)
+               return;
+
+       /* We don't want people slaying init.  */
+       if (p->exit_signal != -1)
+               p->exit_signal = SIGCHLD;
+               
+       if (p->pdeath_signal)
+               /* We already hold the tasklist_lock here.  */
+               group_send_sig_info(p->pdeath_signal, SEND_SIG_NOINFO, p);
+
+       /* If we'd notified the old parent about this child's death,
+        * also notify the new parent.
+        */
+       if (!traced && p->exit_state == EXIT_ZOMBIE &&
+           p->exit_signal != -1 && thread_group_empty(p))
+               do_notify_parent(p, p->exit_signal);
+
        /*
         * process group orphan check
         * Case ii: Our child is in a different pgrp
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to