aboutsummaryrefslogtreecommitdiff
path: root/kernel/exit.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-04-08 23:47:24 +0200
committerAdrian Bunk <bunk@stusta.de>2007-04-08 23:47:24 +0200
commitf95540a5193f909b5700555ceafc69bcb13d2174 (patch)
treebe1853eff7173c0dcd2881b36433db2a1911ce0d /kernel/exit.c
parent928fb605c9107cc5c4e4e77d99ea455651a4635f (diff)
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. This fixes the issues identified by Albert Cahalan in thread http://lkml.org/lkml/2006/12/21/22 Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Adrian Bunk <bunk@stusta.de>
Diffstat (limited to 'kernel/exit.c')
-rw-r--r--kernel/exit.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index fc46c9a86d2..00f0821726f 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -548,10 +548,6 @@ static inline void choose_new_parent(task_t *p, task_t *reaper, task_t *child_re
static void reparent_thread(task_t *p, task_t *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);
@@ -571,13 +567,7 @@ static void reparent_thread(task_t *p, task_t *father, int traced)
p->parent = p->real_parent;
list_add_tail(&p->sibling, &p->parent->children);
- /* 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
@@ -587,6 +577,23 @@ static void reparent_thread(task_t *p, task_t *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 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