提交 7e695a5e 编写于 作者: O Oleg Nesterov 提交者: Linus Torvalds

signals: fold sig_ignored() into handle_stop_signal()

Rename handle_stop_signal() to prepare_signal(), make it return a boolean, and
move the callsites of sig_ignored() into it.

No functional changes for now.  But it would be nice to factor out the "should
we drop this signal" checks as much as possible, before we try to fix the bugs
with the sub-namespace init's signals (actually the global /sbin/init has some
problems with signals too).
Signed-off-by: NOleg Nesterov <oleg@tv-sign.ru>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 2dce81bf
...@@ -558,24 +558,25 @@ static int check_kill_permission(int sig, struct siginfo *info, ...@@ -558,24 +558,25 @@ static int check_kill_permission(int sig, struct siginfo *info,
static void do_notify_parent_cldstop(struct task_struct *tsk, int why); static void do_notify_parent_cldstop(struct task_struct *tsk, int why);
/* /*
* Handle magic process-wide effects of stop/continue signals. * Handle magic process-wide effects of stop/continue signals. Unlike
* Unlike the signal actions, these happen immediately at signal-generation * the signal actions, these happen immediately at signal-generation
* time regardless of blocking, ignoring, or handling. This does the * time regardless of blocking, ignoring, or handling. This does the
* actual continuing for SIGCONT, but not the actual stopping for stop * actual continuing for SIGCONT, but not the actual stopping for stop
* signals. The process stop is done as a signal action for SIG_DFL. * signals. The process stop is done as a signal action for SIG_DFL.
*
* Returns true if the signal should be actually delivered, otherwise
* it should be dropped.
*/ */
static void handle_stop_signal(int sig, struct task_struct *p) static int prepare_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;
if (signal->flags & SIGNAL_GROUP_EXIT) if (unlikely(signal->flags & SIGNAL_GROUP_EXIT)) {
/* /*
* The process is in the middle of dying already. * The process is in the middle of dying, nothing to do.
*/ */
return; } else if (sig_kernel_stop(sig)) {
if (sig_kernel_stop(sig)) {
/* /*
* This is a stop signal. Remove SIGCONT from all queues. * This is a stop signal. Remove SIGCONT from all queues.
*/ */
...@@ -644,6 +645,8 @@ static void handle_stop_signal(int sig, struct task_struct *p) ...@@ -644,6 +645,8 @@ static void handle_stop_signal(int sig, struct task_struct *p)
signal->flags &= ~SIGNAL_STOP_DEQUEUED; signal->flags &= ~SIGNAL_STOP_DEQUEUED;
} }
} }
return !sig_ignored(p, sig);
} }
/* /*
...@@ -753,7 +756,8 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t, ...@@ -753,7 +756,8 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
struct sigqueue *q; struct sigqueue *q;
assert_spin_locked(&t->sighand->siglock); assert_spin_locked(&t->sighand->siglock);
handle_stop_signal(sig, t); if (!prepare_signal(sig, t))
return 0;
pending = group ? &t->signal->shared_pending : &t->pending; pending = group ? &t->signal->shared_pending : &t->pending;
/* /*
...@@ -761,7 +765,7 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t, ...@@ -761,7 +765,7 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
* exactly one non-rt signal, so that we can get more * exactly one non-rt signal, so that we can get more
* detailed information about the cause of the signal. * detailed information about the cause of the signal.
*/ */
if (sig_ignored(t, sig) || legacy_queue(pending, sig)) if (legacy_queue(pending, sig))
return 0; return 0;
/* /*
...@@ -1247,10 +1251,8 @@ int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group) ...@@ -1247,10 +1251,8 @@ int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group)
if (!likely(lock_task_sighand(t, &flags))) if (!likely(lock_task_sighand(t, &flags)))
goto ret; goto ret;
handle_stop_signal(sig, t); ret = 1; /* the signal is ignored */
if (!prepare_signal(sig, t))
ret = 1;
if (sig_ignored(t, sig))
goto out; goto out;
ret = 0; ret = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册