Commit a969214c authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] wait4-fix-2.5.34-A0, BK-curr

the attached patch (against BK-curr) fixes a sys_wait4() bug noticed by
Ulrich Drepper. The kernel would not block properly if there are eligible
children delayed due to the new delayed thread-group-leader logic. The
solution is to introduce a new type of 'eligible child' type - and skip
over delayed children but set the wait4 flag nevertheless.

The libpthreads testcase that failed due to it now it works fine.
parent c7ce0140
...@@ -731,7 +731,7 @@ static int eligible_child(pid_t pid, int options, task_t *p) ...@@ -731,7 +731,7 @@ static int eligible_child(pid_t pid, int options, task_t *p)
* in a non-empty thread group: * in a non-empty thread group:
*/ */
if (current->tgid != p->tgid && delay_group_leader(p)) if (current->tgid != p->tgid && delay_group_leader(p))
return 0; return 2;
if (security_ops->task_wait(p)) if (security_ops->task_wait(p))
return 0; return 0;
...@@ -757,11 +757,21 @@ asmlinkage long sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struc ...@@ -757,11 +757,21 @@ asmlinkage long sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struc
do { do {
struct task_struct *p; struct task_struct *p;
struct list_head *_p; struct list_head *_p;
int ret;
list_for_each(_p,&tsk->children) { list_for_each(_p,&tsk->children) {
p = list_entry(_p,struct task_struct,sibling); p = list_entry(_p,struct task_struct,sibling);
if (!eligible_child(pid, options, p))
ret = eligible_child(pid, options, p);
if (!ret)
continue; continue;
flag = 1; flag = 1;
/*
* Eligible but we cannot release it yet:
*/
if (ret == 2)
continue;
switch (p->state) { switch (p->state) {
case TASK_STOPPED: case TASK_STOPPED:
if (!p->exit_code) if (!p->exit_code)
......
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