]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - kernel/signal.c
signals: re-assign CLD_CONTINUED notification from the sender to reciever
authorOleg Nesterov <oleg@tv-sign.ru>
Wed, 30 Apr 2008 07:52:44 +0000 (00:52 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 30 Apr 2008 15:29:34 +0000 (08:29 -0700)
commite442055193e4584218006e616c9bdce0c5e9ae5c
tree5e444253953c2f48c0a194bf8c5799f03bb2e266
parent3b5e9e53c6f31b5a5a0f5c43707503c62bdefa46
signals: re-assign CLD_CONTINUED notification from the sender to reciever

Based on discussion with Jiri and Roland.

In short: currently handle_stop_signal(SIGCONT, p) sends the notification to
p->parent, with this patch p itself notifies its parent when it becomes
running.

handle_stop_signal(SIGCONT) has to drop ->siglock temporary in order to notify
the parent with do_notify_parent_cldstop().  This leads to multiple problems:

- as Jiri Kosina pointed out, the stopped task can resume without
  actually seeing SIGCONT which may have a handler.

- we race with another sig_kernel_stop() signal which may come in
  that window.

- we race with sig_fatal() signals which may set SIGNAL_GROUP_EXIT
  in that window.

- we can't avoid taking tasklist_lock() while sending SIGCONT.

With this patch handle_stop_signal() just sets the new SIGNAL_CLD_CONTINUED
flag in p->signal->flags and returns.  The notification is sent by the first
task which returns from finish_stop() (there should be at least one) or any
other signalled thread from get_signal_to_deliver().

This is a user-visible change.  Say, currently kill(SIGCONT, stopped_child)
can't return without seeing SIGCHLD, with this patch SIGCHLD can be delayed
unpredictably.  Another difference is that if the child is ptraced by another
process, CLD_CONTINUED may be delivered to ->real_parent after ptrace_detach()
while currently it always goes to the tracer which doesn't actually need this
notification.  Hopefully not a problem.

The patch asks for the futher obvious cleanups, I'll send them separately.

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>
include/linux/sched.h
kernel/signal.c