Commit 2acb024d authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Linus Torvalds

signals: consolidate checking for ignored/legacy signals

Two callers for send_signal() - the specific_send_sig_info and the
__group_send_sig_info - both check for sig to be ignored or already queued.

Move these checks into send_signal() and make it return 1 to indicate that the
signal is dropped, but there's no error in this.

Besides, merge comments and spell-check them.

[oleg@tv-sign.ru: simplifications]
Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent af7fff9c
...@@ -667,6 +667,14 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t, ...@@ -667,6 +667,14 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
{ {
struct sigqueue * q = NULL; struct sigqueue * q = NULL;
/*
* Short-circuit ignored signals and support queuing
* exactly one non-rt signal, so that we can get more
* detailed information about the cause of the signal.
*/
if (sig_ignored(t, sig) || legacy_queue(signals, sig))
return 0;
/* /*
* Deliver the signal to listening signalfds. This must be called * Deliver the signal to listening signalfds. This must be called
* with the sighand lock held. * with the sighand lock held.
...@@ -723,7 +731,7 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t, ...@@ -723,7 +731,7 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
out_set: out_set:
sigaddset(&signals->signal, sig); sigaddset(&signals->signal, sig);
return 0; return 1;
} }
int print_fatal_signals; int print_fatal_signals;
...@@ -761,26 +769,18 @@ __setup("print-fatal-signals=", setup_print_fatal_signals); ...@@ -761,26 +769,18 @@ __setup("print-fatal-signals=", setup_print_fatal_signals);
static int static int
specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t) specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
{ {
int ret = 0; int ret;
BUG_ON(!irqs_disabled()); BUG_ON(!irqs_disabled());
assert_spin_locked(&t->sighand->siglock); assert_spin_locked(&t->sighand->siglock);
/* Short-circuit ignored signals. */
if (sig_ignored(t, sig))
goto out;
/* Support queueing exactly one non-rt signal, so that we
can get more detailed information about the cause of
the signal. */
if (legacy_queue(&t->pending, sig))
goto out;
ret = send_signal(sig, info, t, &t->pending); ret = send_signal(sig, info, t, &t->pending);
if (!ret && !sigismember(&t->blocked, sig)) if (ret <= 0)
return ret;
if (!sigismember(&t->blocked, sig))
signal_wake_up(t, sig == SIGKILL); signal_wake_up(t, sig == SIGKILL);
out: return 0;
return ret;
} }
/* /*
...@@ -925,26 +925,18 @@ __group_complete_signal(int sig, struct task_struct *p) ...@@ -925,26 +925,18 @@ __group_complete_signal(int sig, struct task_struct *p)
int int
__group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p) __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
{ {
int ret = 0; int ret;
assert_spin_locked(&p->sighand->siglock); assert_spin_locked(&p->sighand->siglock);
handle_stop_signal(sig, p); handle_stop_signal(sig, p);
/* Short-circuit ignored signals. */
if (sig_ignored(p, sig))
return ret;
if (legacy_queue(&p->signal->shared_pending, sig))
/* This is a non-RT signal and we already have one queued. */
return ret;
/* /*
* Put this signal on the shared-pending queue, or fail with EAGAIN. * Put this signal on the shared-pending queue, or fail with EAGAIN.
* We always use the shared queue for process-wide signals, * We always use the shared queue for process-wide signals,
* to avoid several races. * to avoid several races.
*/ */
ret = send_signal(sig, info, p, &p->signal->shared_pending); ret = send_signal(sig, info, p, &p->signal->shared_pending);
if (unlikely(ret)) if (ret <= 0)
return ret; return ret;
__group_complete_signal(sig, p); __group_complete_signal(sig, p);
......
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