mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tachino Nobuhiro <tachino@open.nm.fujitsu.co.jp>
To: linux-kernel@vger.kernel.org
Subject: [BUG 2.4.6] PPID of a process is set to itself
Date: Tue, 17 Jul 2001 13:21:43 +0900	[thread overview]
Message-ID: <k818gp7s.wl@nisaaru.open.nm.fujitsu.co.jp> (raw)


Hi,

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];

int
func(void *p)
{
	exit(0);
}

int
main(int argc, char *argv[])
{
	clone(func, &stack[2048],
		CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD,
		NULL);

	sleep(1);
	exit(0);
}

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
group?

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->self_exec_id++;
-			p->p_opptr = reaper;
+			p->p_opptr = p == reaper ? child_reaper : reaper;
 			if (p->pdeath_signal) send_sig(p->pdeath_signal, p, 0);
 		}
 	}

             reply	other threads:[~2001-07-17  4:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-17  4:21 Tachino Nobuhiro [this message]
2001-07-17  4:41 ` Linus Torvalds
2001-07-17  6:10 ` Tachino Nobuhiro
2001-07-17  6:40   ` Linus Torvalds
2001-07-17  7:08     ` Ulrich Drepper
2001-07-17 23:13       ` huge number of context switches under 2.2.x with SMP & threaded apps bert hubert
2001-07-17 23:29         ` huge number of context switches under 2.2.x with SMP & threa Davide Libenzi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=k818gp7s.wl@nisaaru.open.nm.fujitsu.co.jp \
    --to=tachino@open.nm.fujitsu.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®