Commit 961c4675c75112717705fa5c0c53cb9664051479
1 parent
bb188d7e64
Exists in
master
and in
6 other branches
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: Oleg Nesterov <oleg@redhat.com> Acked-by: Tejun Heo <tj@kernel.org>
Showing 1 changed file with 5 additions and 7 deletions Side-by-side Diff
kernel/exit.c
... | ... | @@ -266,18 +266,16 @@ |
266 | 266 | return retval; |
267 | 267 | } |
268 | 268 | |
269 | -static int has_stopped_jobs(struct pid *pgrp) | |
269 | +static bool has_stopped_jobs(struct pid *pgrp) | |
270 | 270 | { |
271 | - int retval = 0; | |
272 | 271 | struct task_struct *p; |
273 | 272 | |
274 | 273 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { |
275 | - if (!task_is_stopped(p)) | |
276 | - continue; | |
277 | - retval = 1; | |
278 | - break; | |
274 | + if (p->signal->flags & SIGNAL_STOP_STOPPED) | |
275 | + return true; | |
279 | 276 | } while_each_pid_task(pgrp, PIDTYPE_PGID, p); |
280 | - return retval; | |
277 | + | |
278 | + return false; | |
281 | 279 | } |
282 | 280 | |
283 | 281 | /* |