Commit 5fcd835b authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

signals: use __group_complete_signal() for the specific signals too

Based on Pavel Emelyanov's suggestion.

Rename __group_complete_signal() to complete_signal() and use it to process
the specific signals too.  To do this we simply add the "int group" argument.

This allows us to greatly simply the signal-sending code and adds a useful
behaviour change.  We can avoid the unneeded wakeups for the private signals
because wants_signal() is more clever than sigismember(blocked), but more
importantly we now take into account the fatal specific signals too.

The latter allows us to kill some subtle checks in handle_stop_signal() and
makes the specific/group signal's behaviour more consistent.  For example,
currently sigtimedwait(FATAL_SIGNAL) behaves differently depending on was the
signal sent by kill() or tkill() if the signal was not blocked.

And.  This allows us to tweak/fix the behaviour when the specific signal is
sent to the dying/dead ->group_leader.
Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2ca3515a
...@@ -673,8 +673,7 @@ static inline int wants_signal(int sig, struct task_struct *p) ...@@ -673,8 +673,7 @@ static inline int wants_signal(int sig, struct task_struct *p)
return task_curr(p) || !signal_pending(p); return task_curr(p) || !signal_pending(p);
} }
static void static void complete_signal(int sig, struct task_struct *p, int group)
__group_complete_signal(int sig, struct task_struct *p)
{ {
struct signal_struct *signal = p->signal; struct signal_struct *signal = p->signal;
struct task_struct *t; struct task_struct *t;
...@@ -687,7 +686,7 @@ __group_complete_signal(int sig, struct task_struct *p) ...@@ -687,7 +686,7 @@ __group_complete_signal(int sig, struct task_struct *p)
*/ */
if (wants_signal(sig, p)) if (wants_signal(sig, p))
t = p; t = p;
else if (thread_group_empty(p)) else if (!group || thread_group_empty(p))
/* /*
* There is just one thread and it does not need to be woken. * There is just one thread and it does not need to be woken.
* It will dequeue unblocked signals before it runs again. * It will dequeue unblocked signals before it runs again.
...@@ -871,8 +870,7 @@ specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t) ...@@ -871,8 +870,7 @@ specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
if (ret <= 0) if (ret <= 0)
return ret; return ret;
if (!sigismember(&t->blocked, sig)) complete_signal(sig, t, 0);
signal_wake_up(t, sig == SIGKILL);
return 0; return 0;
} }
...@@ -930,7 +928,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p) ...@@ -930,7 +928,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
if (ret <= 0) if (ret <= 0)
return ret; return ret;
__group_complete_signal(sig, p); complete_signal(sig, p, 1);
return 0; return 0;
} }
...@@ -1309,8 +1307,7 @@ int send_sigqueue(int sig, struct sigqueue *q, struct task_struct *p) ...@@ -1309,8 +1307,7 @@ int send_sigqueue(int sig, struct sigqueue *q, struct task_struct *p)
ret = do_send_sigqueue(sig, q, p, 0); ret = do_send_sigqueue(sig, q, p, 0);
if (!sigismember(&p->blocked, sig)) complete_signal(sig, p, 0);
signal_wake_up(p, sig == SIGKILL);
unlock_task_sighand(p, &flags); unlock_task_sighand(p, &flags);
out_err: out_err:
...@@ -1330,7 +1327,7 @@ send_group_sigqueue(int sig, struct sigqueue *q, struct task_struct *p) ...@@ -1330,7 +1327,7 @@ send_group_sigqueue(int sig, struct sigqueue *q, struct task_struct *p)
ret = do_send_sigqueue(sig, q, p, 1); ret = do_send_sigqueue(sig, q, p, 1);
__group_complete_signal(sig, p); complete_signal(sig, p, 1);
spin_unlock_irqrestore(&p->sighand->siglock, flags); spin_unlock_irqrestore(&p->sighand->siglock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment