mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 13:44:15 +08:00
handle_stop_signal: unify partial/full stop handling
Now that handle_stop_signal() doesn't drop ->siglock, we can't see both ->group_stop_count && SIGNAL_STOP_STOPPED. Merge two "if" branches. As Roland pointed out, we never actually needed 2 do_notify_parent_cldstop() calls. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: Roland McGrath <roland@redhat.com> Cc: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
6ca25b5513
commit
fc321d2e60
@ -585,33 +585,16 @@ static void handle_stop_signal(int sig, struct task_struct *p)
|
|||||||
t = next_thread(t);
|
t = next_thread(t);
|
||||||
} while (t != p);
|
} while (t != p);
|
||||||
} else if (sig == SIGCONT) {
|
} else if (sig == SIGCONT) {
|
||||||
|
unsigned int why;
|
||||||
/*
|
/*
|
||||||
* Remove all stop signals from all queues,
|
* Remove all stop signals from all queues,
|
||||||
* and wake all threads.
|
* and wake all threads.
|
||||||
*/
|
*/
|
||||||
if (unlikely(p->signal->group_stop_count > 0)) {
|
|
||||||
/*
|
|
||||||
* There was a group stop in progress. We'll
|
|
||||||
* pretend it finished before we got here. We are
|
|
||||||
* obliged to report it to the parent: if the
|
|
||||||
* SIGSTOP happened "after" this SIGCONT, then it
|
|
||||||
* would have cleared this pending SIGCONT. If it
|
|
||||||
* happened "before" this SIGCONT, then the parent
|
|
||||||
* got the SIGCHLD about the stop finishing before
|
|
||||||
* the continue happened. We do the notification
|
|
||||||
* now, and it's as if the stop had finished and
|
|
||||||
* the SIGCHLD was pending on entry to this kill.
|
|
||||||
*/
|
|
||||||
p->signal->group_stop_count = 0;
|
|
||||||
p->signal->flags = SIGNAL_STOP_CONTINUED |
|
|
||||||
SIGNAL_CLD_STOPPED;
|
|
||||||
}
|
|
||||||
rm_from_queue(SIG_KERNEL_STOP_MASK, &p->signal->shared_pending);
|
rm_from_queue(SIG_KERNEL_STOP_MASK, &p->signal->shared_pending);
|
||||||
t = p;
|
t = p;
|
||||||
do {
|
do {
|
||||||
unsigned int state;
|
unsigned int state;
|
||||||
rm_from_queue(SIG_KERNEL_STOP_MASK, &t->pending);
|
rm_from_queue(SIG_KERNEL_STOP_MASK, &t->pending);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is a handler for SIGCONT, we must make
|
* If there is a handler for SIGCONT, we must make
|
||||||
* sure that no thread returns to user mode before
|
* sure that no thread returns to user mode before
|
||||||
@ -636,13 +619,23 @@ static void handle_stop_signal(int sig, struct task_struct *p)
|
|||||||
t = next_thread(t);
|
t = next_thread(t);
|
||||||
} while (t != p);
|
} while (t != p);
|
||||||
|
|
||||||
if (p->signal->flags & SIGNAL_STOP_STOPPED) {
|
|
||||||
/*
|
/*
|
||||||
* We were in fact stopped, and are now continued.
|
* Notify the parent with CLD_CONTINUED if we were stopped.
|
||||||
* Notify the parent with CLD_CONTINUED.
|
*
|
||||||
|
* If we were in the middle of a group stop, we pretend it
|
||||||
|
* was already finished, and then continued. Since SIGCHLD
|
||||||
|
* doesn't queue we report only CLD_STOPPED, as if the next
|
||||||
|
* CLD_CONTINUED was dropped.
|
||||||
*/
|
*/
|
||||||
p->signal->flags = SIGNAL_STOP_CONTINUED |
|
why = 0;
|
||||||
SIGNAL_CLD_CONTINUED;
|
if (p->signal->flags & SIGNAL_STOP_STOPPED)
|
||||||
|
why |= SIGNAL_CLD_CONTINUED;
|
||||||
|
else if (p->signal->group_stop_count)
|
||||||
|
why |= SIGNAL_CLD_STOPPED;
|
||||||
|
|
||||||
|
if (why) {
|
||||||
|
p->signal->flags = why | SIGNAL_STOP_CONTINUED;
|
||||||
|
p->signal->group_stop_count = 0;
|
||||||
p->signal->group_exit_code = 0;
|
p->signal->group_exit_code = 0;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user