Skip to content

Commit 0edceb7

Browse files
committed
signal: introduce retarget_shared_pending()
No functional changes. Move the notify-other-threads code from exit_signals() to the new helper, retarget_shared_pending(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: Matt Fleming <matt.fleming@linux.intel.com> Acked-by: Tejun Heo <tj@kernel.org>
1 parent e46bc9b commit 0edceb7

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

kernel/signal.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,10 +2198,25 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
21982198
return signr;
21992199
}
22002200

2201+
/*
2202+
* It could be that complete_signal() picked us to notify about the
2203+
* group-wide signal. Another thread should be notified now to take
2204+
* the signal since we will not.
2205+
*/
2206+
static void retarget_shared_pending(struct task_struct *tsk)
2207+
{
2208+
struct task_struct *t;
2209+
2210+
t = tsk;
2211+
while_each_thread(tsk, t) {
2212+
if (!signal_pending(t) && !(t->flags & PF_EXITING))
2213+
recalc_sigpending_and_wake(t);
2214+
}
2215+
}
2216+
22012217
void exit_signals(struct task_struct *tsk)
22022218
{
22032219
int group_stop = 0;
2204-
struct task_struct *t;
22052220

22062221
if (thread_group_empty(tsk) || signal_group_exit(tsk->signal)) {
22072222
tsk->flags |= PF_EXITING;
@@ -2217,14 +2232,7 @@ void exit_signals(struct task_struct *tsk)
22172232
if (!signal_pending(tsk))
22182233
goto out;
22192234

2220-
/*
2221-
* It could be that __group_complete_signal() choose us to
2222-
* notify about group-wide signal. Another thread should be
2223-
* woken now to take the signal since we will not.
2224-
*/
2225-
for (t = tsk; (t = next_thread(t)) != tsk; )
2226-
if (!signal_pending(t) && !(t->flags & PF_EXITING))
2227-
recalc_sigpending_and_wake(t);
2235+
retarget_shared_pending(tsk);
22282236

22292237
if (unlikely(tsk->group_stop & GROUP_STOP_PENDING) &&
22302238
task_participate_group_stop(tsk))

0 commit comments

Comments
 (0)