Commit 8677347378044ab564470bced2275520efb3670d
1 parent
9843a1e977
Exists in
master
and in
6 other branches
make do_notify_parent() __must_check, update the callers
Change other callers of do_notify_parent() to check the value it returns, this makes the subsequent task_detached() unnecessary. Mark do_notify_parent() as __must_check. Use thread_group_leader() instead of !task_detached() to check if we need to notify the real parent in wait_task_zombie(). Remove the stale comment in release_task(). "just for sanity" is no longer true, we have to set EXIT_DEAD to avoid the races with do_wait(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Tejun Heo <tj@kernel.org>
Showing 2 changed files with 9 additions and 22 deletions Side-by-side Diff
include/linux/sched.h
... | ... | @@ -2160,7 +2160,7 @@ |
2160 | 2160 | extern int kill_pgrp(struct pid *pid, int sig, int priv); |
2161 | 2161 | extern int kill_pid(struct pid *pid, int sig, int priv); |
2162 | 2162 | extern int kill_proc_info(int, struct siginfo *, pid_t); |
2163 | -extern bool do_notify_parent(struct task_struct *, int); | |
2163 | +extern __must_check bool do_notify_parent(struct task_struct *, int); | |
2164 | 2164 | extern void __wake_up_parent(struct task_struct *p, struct task_struct *parent); |
2165 | 2165 | extern void force_sig(int, struct task_struct *); |
2166 | 2166 | extern int send_sig(int, struct task_struct *, int); |
kernel/exit.c
... | ... | @@ -190,21 +190,12 @@ |
190 | 190 | leader = p->group_leader; |
191 | 191 | if (leader != p && thread_group_empty(leader) && leader->exit_state == EXIT_ZOMBIE) { |
192 | 192 | BUG_ON(task_detached(leader)); |
193 | - do_notify_parent(leader, leader->exit_signal); | |
194 | 193 | /* |
195 | 194 | * If we were the last child thread and the leader has |
196 | 195 | * exited already, and the leader's parent ignores SIGCHLD, |
197 | 196 | * then we are the one who should release the leader. |
198 | - * | |
199 | - * do_notify_parent() will have marked it self-reaping in | |
200 | - * that case. | |
201 | 197 | */ |
202 | - zap_leader = task_detached(leader); | |
203 | - | |
204 | - /* | |
205 | - * This maintains the invariant that release_task() | |
206 | - * only runs on a task in EXIT_DEAD, just for sanity. | |
207 | - */ | |
198 | + zap_leader = do_notify_parent(leader, leader->exit_signal); | |
208 | 199 | if (zap_leader) |
209 | 200 | leader->exit_state = EXIT_DEAD; |
210 | 201 | } |
... | ... | @@ -766,8 +757,7 @@ |
766 | 757 | /* If it has exited notify the new parent about this child's death. */ |
767 | 758 | if (!p->ptrace && |
768 | 759 | p->exit_state == EXIT_ZOMBIE && thread_group_empty(p)) { |
769 | - do_notify_parent(p, p->exit_signal); | |
770 | - if (task_detached(p)) { | |
760 | + if (do_notify_parent(p, p->exit_signal)) { | |
771 | 761 | p->exit_state = EXIT_DEAD; |
772 | 762 | list_move_tail(&p->sibling, dead); |
773 | 763 | } |
774 | 764 | |
... | ... | @@ -1351,16 +1341,13 @@ |
1351 | 1341 | /* We dropped tasklist, ptracer could die and untrace */ |
1352 | 1342 | ptrace_unlink(p); |
1353 | 1343 | /* |
1354 | - * If this is not a detached task, notify the parent. | |
1355 | - * If it's still not detached after that, don't release | |
1356 | - * it now. | |
1344 | + * If this is not a sub-thread, notify the parent. | |
1345 | + * If parent wants a zombie, don't release it now. | |
1357 | 1346 | */ |
1358 | - if (!task_detached(p)) { | |
1359 | - do_notify_parent(p, p->exit_signal); | |
1360 | - if (!task_detached(p)) { | |
1361 | - p->exit_state = EXIT_ZOMBIE; | |
1362 | - p = NULL; | |
1363 | - } | |
1347 | + if (thread_group_leader(p) && | |
1348 | + !do_notify_parent(p, p->exit_signal)) { | |
1349 | + p->exit_state = EXIT_ZOMBIE; | |
1350 | + p = NULL; | |
1364 | 1351 | } |
1365 | 1352 | write_unlock_irq(&tasklist_lock); |
1366 | 1353 | } |