Also restructure the loop in do_wait()

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
This commit is contained in:
Matthew Wilcox 2007-12-06 11:09:35 -05:00 коммит произвёл Matthew Wilcox
Родитель e1abb39c60
Коммит 338077e54e
1 изменённых файлов: 39 добавлений и 49 удалений

Просмотреть файл

@ -249,7 +249,7 @@ static int has_stopped_jobs(struct pid *pgrp)
struct task_struct *p; struct task_struct *p;
do_each_pid_task(pgrp, PIDTYPE_PGID, p) { do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
if (p->state != TASK_STOPPED) if (!task_is_stopped(p))
continue; continue;
retval = 1; retval = 1;
break; break;
@ -614,7 +614,7 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
p->parent = p->real_parent; p->parent = p->real_parent;
add_parent(p); add_parent(p);
if (p->state == TASK_TRACED) { if (task_is_traced(p)) {
/* /*
* If it was at a trace stop, turn it into * If it was at a trace stop, turn it into
* a normal stop since it's no longer being * a normal stop since it's no longer being
@ -1563,60 +1563,51 @@ repeat:
} }
allowed = 1; allowed = 1;
switch (p->state) { if (task_is_stopped_or_traced(p)) {
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:
/* /*
* It's stopped now, so it might later * It's stopped now, so it might later
* continue, exit, or stop again. * 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; flag = 1;
if (!(options & WUNTRACED) &&
!my_ptrace_child(p)) if (!my_ptrace_child(p)) {
continue; if (task_is_traced(p))
continue;
if (!(options & WUNTRACED))
continue;
}
retval = wait_task_stopped(p, ret == 2, retval = wait_task_stopped(p, ret == 2,
(options & WNOWAIT), (options & WNOWAIT), infop,
infop, stat_addr, ru);
stat_addr, ru);
if (retval == -EAGAIN) if (retval == -EAGAIN)
goto repeat; goto repeat;
if (retval != 0) /* He released the lock. */ if (retval != 0) /* He released the lock. */
goto end; goto end;
break; } else if (p->exit_state == EXIT_DEAD) {
default: continue;
// case EXIT_DEAD: } else if (p->exit_state == EXIT_ZOMBIE) {
if (p->exit_state == EXIT_DEAD) /*
* Eligible but we cannot release it yet:
*/
if (ret == 2)
goto check_continued;
if (!likely(options & WEXITED))
continue; continue;
// case EXIT_ZOMBIE: retval = wait_task_zombie(p,
if (p->exit_state == EXIT_ZOMBIE) { (options & WNOWAIT), infop,
/* stat_addr, ru);
* Eligible but we cannot release /* He released the lock. */
* it yet: if (retval != 0)
*/ goto end;
if (ret == 2) } else {
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;
}
check_continued: check_continued:
/* /*
* It's running now, so it might later * It's running now, so it might later
@ -1625,12 +1616,11 @@ check_continued:
flag = 1; flag = 1;
if (!unlikely(options & WCONTINUED)) if (!unlikely(options & WCONTINUED))
continue; continue;
retval = wait_task_continued( retval = wait_task_continued(p,
p, (options & WNOWAIT), (options & WNOWAIT), infop,
infop, stat_addr, ru); stat_addr, ru);
if (retval != 0) /* He released the lock. */ if (retval != 0) /* He released the lock. */
goto end; goto end;
break;
} }
} }
if (!flag) { if (!flag) {