* signalfd and thread semantics
@ 2007-07-17 20:44 Michael Kerrisk
2007-07-17 22:33 ` Davide Libenzi
0 siblings, 1 reply; 3+ messages in thread
From: Michael Kerrisk @ 2007-07-17 20:44 UTC (permalink / raw)
To: Davide Libenzi; +Cc: lkml
Hi Davide,
Working on the signalfd man page, another question comes up:
What are the intended semantics for a signalfd file descriptor with respect
to threads? I have not yet tested the behavior, but in any case, I better
check what is expected.
A signal can be directed to the process as a whole (e.g., using kill(2)),
or to a particular thread (using, e.g., pthread_kill(2), or tgkill(2)).
So that raises the question: If a thread calls signalfd(), does the
resulting file descriptor return just those signals directed to [the thread
and the process as a whole], or will it also receive signals that are
targeted at other threads in the process? I would hope the former is the
case, but I'm not sure what has been implemented (or intended).
Cheers,
Michael
--
Michael Kerrisk
maintainer of Linux man pages Sections 2, 3, 4, 5, and 7
Want to help with man page maintenance? Grab the latest tarball at
http://www.kernel.org/pub/linux/docs/manpages/
read the HOWTOHELP file and grep the source files for 'FIXME'.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: signalfd and thread semantics
2007-07-17 20:44 signalfd and thread semantics Michael Kerrisk
@ 2007-07-17 22:33 ` Davide Libenzi
2007-07-17 22:40 ` Michael Kerrisk
0 siblings, 1 reply; 3+ messages in thread
From: Davide Libenzi @ 2007-07-17 22:33 UTC (permalink / raw)
To: Michael Kerrisk; +Cc: lkml
On Tue, 17 Jul 2007, Michael Kerrisk wrote:
> Hi Davide,
>
> Working on the signalfd man page, another question comes up:
>
> What are the intended semantics for a signalfd file descriptor with respect
> to threads? I have not yet tested the behavior, but in any case, I better
> check what is expected.
>
> A signal can be directed to the process as a whole (e.g., using kill(2)),
> or to a particular thread (using, e.g., pthread_kill(2), or tgkill(2)).
>
> So that raises the question: If a thread calls signalfd(), does the
> resulting file descriptor return just those signals directed to [the thread
> and the process as a whole], or will it also receive signals that are
> targeted at other threads in the process? I would hope the former is the
> case, but I'm not sure what has been implemented (or intended).
If thread A calls signalfd(), a read() from the signalfd will return
thread A private (tgkill) signals (only when called by thread A) and
thread A shared (kill) signals (readable from any thread).
So a call to signalfd() virtually attaches the fd to the calling thread
signal context.
This is the reason of the "virtual connection" dropped I was talking about
in the other email. If the signal context the fd is attached to
(struct sighand), goes away, the fd becomes like a disconnected socket
with no peer to read form.
- Davide
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: signalfd and thread semantics
2007-07-17 22:33 ` Davide Libenzi
@ 2007-07-17 22:40 ` Michael Kerrisk
0 siblings, 0 replies; 3+ messages in thread
From: Michael Kerrisk @ 2007-07-17 22:40 UTC (permalink / raw)
To: Davide Libenzi; +Cc: linux-kernel
> On Tue, 17 Jul 2007, Michael Kerrisk wrote:
>
> > Hi Davide,
> >
> > Working on the signalfd man page, another question comes up:
> >
> > What are the intended semantics for a signalfd file descriptor with
> > respect to threads? I have not yet tested the behavior, but in
> > any case, I better check what is expected.
> >
> > A signal can be directed to the process as a whole (e.g., using
> > kill(2)), or to a particular thread (using, e.g., pthread_kill(2),
> > or tgkill(2)).
> >
> > So that raises the question: If a thread calls signalfd(), does the
> > resulting file descriptor return just those signals directed to [the
> > thread and the process as a whole], or will it also receive signals
> > that are targeted at other threads in the process? I would hope the
> > former is the case, but I'm not sure what has been implemented
> > (or intended).
>
> If thread A calls signalfd(), a read() from the signalfd will return
> thread A private (tgkill) signals (only when called by thread A) and
> thread A shared (kill) signals (readable from any thread).
> So a call to signalfd() virtually attaches the fd to the calling thread
> signal context.
> This is the reason of the "virtual connection" dropped I was talking
> about in the other email. If the signal context the fd is attached to
> (struct sighand), goes away, the fd becomes like a disconnected socket
> with no peer to read form.
It's late at night, and perhaps I am being slow: in what
circumstances can the signal context go away while the
thread itself continues to live? (I mean in
what circumstances from the point of view of the userland
program?)
Cheers,
Michael
--
Michael Kerrisk
maintainer of Linux man pages Sections 2, 3, 4, 5, and 7
Want to help with man page maintenance?
Grab the latest tarball at
http://www.kernel.org/pub/linux/docs/manpages ,
read the HOWTOHELP file and grep the source
files for 'FIXME'.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-17 22:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-17 20:44 signalfd and thread semantics Michael Kerrisk
2007-07-17 22:33 ` Davide Libenzi
2007-07-17 22:40 ` Michael Kerrisk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox