Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 84655
b: refs/heads/master
c: f2cc3eb
h: refs/heads/master
i:
  84653: b49faaf
  84651: 959df5d
  84647: 9bf711b
  84639: 7d3a65a
v: v3
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Feb 8, 2008
1 parent a338f1c commit ba55246
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 96fabbf55ae79826f2e8a86f4066d7e8834315ae
refs/heads/master: f2cc3eb133baa2e9dc8efd40f417106b2ee520f3
39 changes: 18 additions & 21 deletions trunk/kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1142,10 +1142,14 @@ static int eligible_child(pid_t pid, int options, struct task_struct *p)
return 0;

err = security_task_wait(p);
if (err)
return err;
if (likely(!err))
return 1;

return 1;
if (pid <= 0)
return 0;
/* This child was explicitly requested, abort */
read_unlock(&tasklist_lock);
return err;
}

static int wait_noreap_copyout(struct task_struct *p, pid_t pid, uid_t uid,
Expand Down Expand Up @@ -1476,16 +1480,14 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
DECLARE_WAITQUEUE(wait, current);
struct task_struct *tsk;
int flag, retval;
int allowed, denied;

add_wait_queue(&current->signal->wait_chldexit,&wait);
repeat:
/*
* We will set this flag if we see any child that might later
* match our criteria, even if we are not able to reap it yet.
*/
flag = 0;
allowed = denied = 0;
flag = retval = 0;
current->state = TASK_INTERRUPTIBLE;
read_lock(&tasklist_lock);
tsk = current;
Expand All @@ -1498,13 +1500,8 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
continue;

if (unlikely(ret < 0)) {
denied = ret;
continue;
}
allowed = 1;

retval = 0;
if (task_is_stopped_or_traced(p)) {
retval = ret;
} else if (task_is_stopped_or_traced(p)) {
/*
* It's stopped now, so it might later
* continue, exit, or stop again.
Expand Down Expand Up @@ -1544,22 +1541,24 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
}
if (!flag) {
list_for_each_entry(p, &tsk->ptrace_children,
ptrace_list) {
if (!eligible_child(pid, options, p))
ptrace_list) {
flag = eligible_child(pid, options, p);
if (!flag)
continue;
flag = 1;
break;
if (likely(flag > 0))
break;
retval = flag;
goto end;
}
}
if (options & __WNOTHREAD)
break;
tsk = next_thread(tsk);
BUG_ON(tsk->signal != current->signal);
} while (tsk != current);

read_unlock(&tasklist_lock);

if (flag) {
retval = 0;
if (options & WNOHANG)
goto end;
retval = -ERESTARTSYS;
Expand All @@ -1569,8 +1568,6 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
goto repeat;
}
retval = -ECHILD;
if (unlikely(denied) && !allowed)
retval = denied;
end:
current->state = TASK_RUNNING;
remove_wait_queue(&current->signal->wait_chldexit,&wait);
Expand Down

0 comments on commit ba55246

Please sign in to comment.