提交 961c4675 编写于 作者: O Oleg Nesterov

has_stopped_jobs: s/task_is_stopped/SIGNAL_STOP_STOPPED/

has_stopped_jobs() naively checks task_is_stopped(group_leader). This
was always wrong even without ptrace, group_leader can be dead. And
given that ptrace can change the state to TRACED this is wrong even
in the single-threaded case.

Change the code to check SIGNAL_STOP_STOPPED and simplify the code,
retval + break/continue doesn't make this trivial code more readable.

We could probably add the usual "|| signal->group_stop_count" check
but I don't think this makes sense, the task can start the group-stop
right after the check anyway.
Signed-off-by: NOleg Nesterov <oleg@redhat.com>
Acked-by: NTejun Heo <tj@kernel.org>
上级 bb188d7e
...@@ -266,18 +266,16 @@ int is_current_pgrp_orphaned(void) ...@@ -266,18 +266,16 @@ int is_current_pgrp_orphaned(void)
return retval; return retval;
} }
static int has_stopped_jobs(struct pid *pgrp) static bool has_stopped_jobs(struct pid *pgrp)
{ {
int retval = 0;
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 (!task_is_stopped(p)) if (p->signal->flags & SIGNAL_STOP_STOPPED)
continue; return true;
retval = 1;
break;
} while_each_pid_task(pgrp, PIDTYPE_PGID, p); } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
return retval;
return false;
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册