From: Oleg Nesterov <oleg@redhat.com>
To: Roland McGrath <roland@redhat.com>
Cc: Kaz Kylheku <kkylheku@gmail.com>,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Ulrich Drepper <drepper@redhat.com>
Subject: Re: main thread pthread_exit/sys_exit bug!
Date: Mon, 9 Feb 2009 06:14:00 +0100 [thread overview]
Message-ID: <20090209051400.GA5450@redhat.com> (raw)
In-Reply-To: <20090209045234.GA3213@redhat.com>
On 02/09, Oleg Nesterov wrote:
>
> Yes sure. I meant, instead of just checking task_is_stopped_or_traced() in
> wait_consider_task(), we should do somthing like
In short, please see the "patch" below. I doubt it can be compiled,
just for the illustration.
Oleg.
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1417,6 +1417,19 @@ static int wait_task_zombie(struct task_
return retval;
}
+static int *wait_xxx(struct task_struct *p, int ptrace)
+{
+ if (ptrace) {
+ if (task_is_stopped_or_traced(p))
+ return &p->exit_code;
+ } else {
+ if (p->signal->flags & SIGNAL_STOPPED_STOPPED)
+ return &p->signal->group_exit_code;
+ }
+
+ return NULL;
+}
+
/*
* Handle sys_wait4 work for one task in state TASK_STOPPED. We hold
* read_lock(&tasklist_lock) on entry. If we return zero, we still hold
@@ -1427,7 +1440,7 @@ static int wait_task_stopped(int ptrace,
int options, struct siginfo __user *infop,
int __user *stat_addr, struct rusage __user *ru)
{
- int retval, exit_code, why;
+ int retval, exit_code, *p_code, why;
uid_t uid = 0; /* unneeded, required by compiler */
pid_t pid;
@@ -1437,22 +1450,16 @@ static int wait_task_stopped(int ptrace,
exit_code = 0;
spin_lock_irq(&p->sighand->siglock);
- if (unlikely(!task_is_stopped_or_traced(p)))
- goto unlock_sig;
-
- if (!ptrace && p->signal->group_stop_count > 0)
- /*
- * A group stop is in progress and this is the group leader.
- * We won't report until all threads have stopped.
- */
+ p_code = wait_xxx(p, ptrace);
+ if (unlikely(!p_code))
goto unlock_sig;
- exit_code = p->exit_code;
+ exit_code = *p_code;
if (!exit_code)
goto unlock_sig;
if (!unlikely(options & WNOWAIT))
- p->exit_code = 0;
+ *p_code = 0;
/* don't need the RCU readlock here as we're holding a spinlock */
uid = __task_cred(p)->uid;
@@ -1608,7 +1615,7 @@ static int wait_consider_task(struct tas
*/
*notask_error = 0;
- if (task_is_stopped_or_traced(p))
+ if (wait_xxx(p, ptrace))
return wait_task_stopped(ptrace, p, options,
infop, stat_addr, ru);
prev parent reply other threads:[~2009-02-09 5:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-01 22:32 main thread pthread_exit/sys_exit bug! Kaz Kylheku
[not found] ` <20090201174159.4a52e15c.akpm@linux-foundation.org>
2009-02-02 6:45 ` Oleg Nesterov
2009-02-02 7:10 ` Kaz Kylheku
2009-02-02 16:56 ` Oleg Nesterov
2009-02-02 20:10 ` Kaz Kylheku
2009-02-02 20:17 ` Ulrich Drepper
2009-02-02 20:39 ` Kaz Kylheku
2009-02-03 2:39 ` Kaz Kylheku
2009-02-03 13:33 ` Oleg Nesterov
2009-02-03 19:51 ` Kaz Kylheku
2009-02-03 21:32 ` Oleg Nesterov
2009-02-03 23:06 ` Kaz Kylheku
2009-02-05 3:05 ` Roland McGrath
2009-02-05 4:55 ` Kaz Kylheku
2009-02-05 16:15 ` Oleg Nesterov
2009-02-05 21:22 ` Roland McGrath
2009-02-05 23:22 ` Oleg Nesterov
2009-02-09 3:33 ` Roland McGrath
2009-02-09 4:52 ` Oleg Nesterov
2009-02-09 5:14 ` Oleg Nesterov [this message]
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=20090209051400.GA5450@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=drepper@redhat.com \
--cc=kkylheku@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.