Commit 338077e5 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Matthew Wilcox

exit: Use task_is_*

Also restructure the loop in do_wait()
Signed-off-by: default avatarMatthew Wilcox <willy@linux.intel.com>
parent e1abb39c
......@@ -249,7 +249,7 @@ static int has_stopped_jobs(struct pid *pgrp)
struct task_struct *p;
do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
if (p->state != TASK_STOPPED)
if (!task_is_stopped(p))
continue;
retval = 1;
break;
......@@ -614,7 +614,7 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
p->parent = p->real_parent;
add_parent(p);
if (p->state == TASK_TRACED) {
if (task_is_traced(p)) {
/*
* If it was at a trace stop, turn it into
* a normal stop since it's no longer being
......@@ -1563,60 +1563,51 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
}
allowed = 1;
switch (p->state) {
case TASK_TRACED:
/*
* When we hit the race with PTRACE_ATTACH,
* we will not report this child. But the
* race means it has not yet been moved to
* our ptrace_children list, so we need to
* set the flag here to avoid a spurious ECHILD
* when the race happens with the only child.
*/
flag = 1;
if (!my_ptrace_child(p))
continue;
/*FALLTHROUGH*/
case TASK_STOPPED:
if (task_is_stopped_or_traced(p)) {
/*
* It's stopped now, so it might later
* continue, exit, or stop again.
*
* When we hit the race with PTRACE_ATTACH, we
* will not report this child. But the race
* means it has not yet been moved to our
* ptrace_children list, so we need to set the
* flag here to avoid a spurious ECHILD when
* the race happens with the only child.
*/
flag = 1;
if (!(options & WUNTRACED) &&
!my_ptrace_child(p))
continue;
if (!my_ptrace_child(p)) {
if (task_is_traced(p))
continue;
if (!(options & WUNTRACED))
continue;
}
retval = wait_task_stopped(p, ret == 2,
(options & WNOWAIT),
infop,
stat_addr, ru);
(options & WNOWAIT), infop,
stat_addr, ru);
if (retval == -EAGAIN)
goto repeat;
if (retval != 0) /* He released the lock. */
goto end;
break;
default:
// case EXIT_DEAD:
if (p->exit_state == EXIT_DEAD)
} else if (p->exit_state == EXIT_DEAD) {
continue;
} else if (p->exit_state == EXIT_ZOMBIE) {
/*
* Eligible but we cannot release it yet:
*/
if (ret == 2)
goto check_continued;
if (!likely(options & WEXITED))
continue;
// case EXIT_ZOMBIE:
if (p->exit_state == EXIT_ZOMBIE) {
/*
* Eligible but we cannot release
* it yet:
*/
if (ret == 2)
goto check_continued;
if (!likely(options & WEXITED))
continue;
retval = wait_task_zombie(
p, (options & WNOWAIT),
infop, stat_addr, ru);
/* He released the lock. */
if (retval != 0)
goto end;
break;
}
retval = wait_task_zombie(p,
(options & WNOWAIT), infop,
stat_addr, ru);
/* He released the lock. */
if (retval != 0)
goto end;
} else {
check_continued:
/*
* It's running now, so it might later
......@@ -1625,12 +1616,11 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
flag = 1;
if (!unlikely(options & WCONTINUED))
continue;
retval = wait_task_continued(
p, (options & WNOWAIT),
infop, stat_addr, ru);
retval = wait_task_continued(p,
(options & WNOWAIT), infop,
stat_addr, ru);
if (retval != 0) /* He released the lock. */
goto end;
break;
}
}
if (!flag) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment