From: Oleg Nesterov <oleg@tv-sign.ru>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Albert Cahalan <acahalan@gmail.com>,
Alexey Dobriyan <adobriyan@openvz.org>,
Michael Kerrisk <mtk.manpages@googlemail.com>,
Roland McGrath <roland@redhat.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] proc: don't confuse /bin/ps by zombie delay_group_leader's
Date: Sat, 30 Aug 2008 21:08:41 +0400 [thread overview]
Message-ID: <20080830170841.GA7887@tv-sign.ru> (raw)
When the main thread exits,
void *do_thread(void *arg)
{
pause();
return NULL;
}
int main(void)
{
pthread_t thr;
pthread_create(&thr, NULL, do_thread, NULL);
syscall(__NR_exit, 0);
return 0;
}
/bin/ps's output looks really confusing, as if the whole process is dead.
I think this even looks like a kernel bug to the user, because it sees a
zombie which is not going to be reaped.
Change get_task_state() to report "S (sleeping)" in this case. Still not
perfect because the task can be confused with the kernel thread (its ->mm
is NULL), but imho better anyway.
Also, uninline get_task_state(), it has 2 callers.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
--- 2.6.27-rc4/fs/proc/array.c~ZOMBIE_LEADER 2008-07-30 13:12:47.000000000 +0400
+++ 2.6.27-rc4/fs/proc/array.c 2008-08-30 18:17:10.000000000 +0400
@@ -146,10 +146,14 @@ static const char *task_state_array[] =
"X (dead)" /* 32 */
};
-static inline const char *get_task_state(struct task_struct *tsk)
+static const char *get_task_state(struct task_struct *tsk)
{
- unsigned int state = (tsk->state & TASK_REPORT) | tsk->exit_state;
const char **p = &task_state_array[0];
+ unsigned int state = tsk->exit_state | (tsk->state & TASK_REPORT);
+
+ /* don't confuse /bin/ps if the whole process is not dead */
+ if (tsk->exit_state && delay_group_leader(tsk))
+ state = TASK_INTERRUPTIBLE;
while (state) {
p++;
next reply other threads:[~2008-08-30 17:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-30 17:08 Oleg Nesterov [this message]
2008-09-01 1:07 ` Roland McGrath
2008-09-01 10:06 ` Oleg Nesterov
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=20080830170841.GA7887@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=acahalan@gmail.com \
--cc=adobriyan@openvz.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtk.manpages@googlemail.com \
--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 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®