patch-2.4.18 linux/kernel/exit.c
Next file: linux/kernel/fork.c
Previous file: linux/kernel/exec_domain.c
Back to the patch index
Back to the overall index
- Lines: 38
- Date:
Wed Dec 26 16:16:25 2001
- Orig file:
linux.orig/kernel/exit.c
- Orig date:
Mon Feb 18 20:18:40 2002
diff -Naur -X /home/marcelo/lib/dontdiff linux.orig/kernel/exit.c linux/kernel/exit.c
@@ -150,21 +150,34 @@
}
/*
- * When we die, we re-parent all our children to
+ * When we die, we re-parent all our children.
+ * Try to give them to another thread in our process
+ * group, and if no such member exists, give it to
* the global child reaper process (ie "init")
*/
static inline void forget_original_parent(struct task_struct * father)
{
- struct task_struct * p;
+ struct task_struct * p, *reaper;
read_lock(&tasklist_lock);
+ /* Next in our thread group */
+ reaper = next_thread(father);
+ if (reaper == father)
+ reaper = child_reaper;
+
for_each_task(p) {
if (p->p_opptr == father) {
/* We dont want people slaying init */
p->exit_signal = SIGCHLD;
p->self_exec_id++;
- p->p_opptr = child_reaper;
+
+ /* Make sure we're not reparenting to ourselves */
+ if (p == reaper)
+ p->p_opptr = child_reaper;
+ else
+ p->p_opptr = reaper;
+
if (p->pdeath_signal) send_sig(p->pdeath_signal, p, 0);
}
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)