Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.4.13-ac8 /kernel/exit.c

Filename:/kernel/exit.c
Lines Added:17
Lines Deleted:3
Also changed in: (Previous) 2.4.13-ac7  2.4.13-ac6  2.4.13-ac5  2.4.13-ac4  2.4.13-ac3  2.4.13-ac1 
(Following) 2.4.15-pre2  2.4.15-pre3  2.4.15-pre4  2.4.15-pre5  2.4.15-pre6  2.4.15-pre7 

Location
[  2.4.13-ac8
  [  kernel
     o  exit.c

Patch

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla/kernel/exit.c linux.ac/kernel/exit.c
--- linux.vanilla/kernel/exit.c   Thu Oct 25 16:26:39 2001
+++ linux.ac/kernel/exit.c   Sun Oct 21 18:38:23 2001
@@ -39,6 +39,7 @@
             break;
          task_unlock(p);
          do {
+            cpu_relax();
             barrier();
          } while (p->has_cpu);
       }
@@ -149,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);
       }
    }


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.