From: Roland McGrath <roland@redhat.com>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sigwait eats blocked default-ignore signals
Date: Tue, 13 Nov 2007 15:32:01 -0800 (PST) [thread overview]
Message-ID: <20071114073249.CEECC26F8B6@magilla.localdomain> (raw)
In-Reply-To: Oleg Nesterov's message of Tuesday, 13 November 2007 18:56:38 +0300 <20071113155638.GB74@tv-sign.ru>
> But I suspect we have other issues here. Let's suppose we have threads T1
> (main) and T2. T2 blocks SIGCHLD and does sigwait(SIGCHLD).
>
> Now, we send SIGCHLD to the thread group. The signal is lost again because
> sig_ignored() returns true on T1's side.
>
> Is this OK? [...]
Yes, it's OK if T1 has SIGCHLD unblocked. When there are multiple threads
that either don't block the signal or are in sigwait for it, then it can go
to any of them and there are no guarantees at all about which. So we
simply say that the signal went to the thread not in sigwait that has that
signal unblocked (T1). When it got there, it was ignored. The user
semantics are equivalent even if that thread never actually woke and
dequeued the signal to ignore it.
> I think __group_send_sig_info() shouldn't use sig_ignored() at
> all. Instead, we should split __group_complete_signal() into 2
> functions. The first one, say, choose_target() shoud be used instead. The
> second one, handle_fatal_signal() can also be used by tkill() and
> friends.
I will probably like any reorganization of the code that makes it cleaner.
But we don't need to change the behavior in this regard. The most common
path is __group_send_sig_info (from sys_kill), so it would be a shame to
remove the short-circuit optimization there. In fact, it is probably wrong
semantics to do so (for what applications expect, and possibly for POSIX
conformance). That is, an unblocked, ignored (or default-ignore) signal
should not set TIF_SIGPENDING and interrupt a system call in progress or
just about to start. Obviously this is not a huge problem, since that's
what happens under any debugger. But still, an undesireable change of
semantics as well as de-optimization, I'd say.
Thanks,
Roland
next prev parent reply other threads:[~2007-11-14 7:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-12 23:41 Roland McGrath
2007-11-13 15:56 ` Oleg Nesterov
2007-11-13 23:32 ` Roland McGrath [this message]
2007-11-14 15:53 ` Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071114073249.CEECC26F8B6@magilla.localdomain \
--to=roland@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®