[BUG 2.4.6] PPID of a process is set to itself

From: Tachino Nobuhiro (tachino@open.nm.fujitsu.co.jp)
Date: Mon Jul 16 2001 - 23:21:43 EST


When I am playing with clone system call, I found the case the cloned process
becomes the zombie which is not reaped because the PPID of the process is
set to itself. The test program are following.

#include <sched.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int stack[2048];

func(void *p)

main(int argc, char *argv[])
        clone(func, &stack[2048],


Following patch fixes the bug, but I don't know this is correct. Can
someone please explain me why in forget_original_parent(), the parent of
processes in a thread group is set to another process in the thread

diff -u -r linux.org/kernel/exit.c linux/kernel/exit.c
--- linux.org/kernel/exit.c Sat May 5 06:44:06 2001
+++ linux/kernel/exit.c Tue Jul 17 11:06:59 2001
@@ -168,7 +168,7 @@
                         /* We dont want people slaying init */
                         p->exit_signal = SIGCHLD;
- p->p_opptr = reaper;
+ p->p_opptr = p == reaper ? child_reaper : reaper;
                         if (p->pdeath_signal) send_sig(p->pdeath_signal, p, 0);
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

This archive was generated by hypermail 2b29 : Mon Jul 23 2001 - 21:00:08 EST