Re: signalfd and thread semantics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux