From: WANG Cong on
On Thu, 29 Jul 2010 13:53:17 +0200, Xavier Roche wrote:

> Ersek, Laszlo wrote:
>> Or block SIGALRM in all other threads.
>
> What for ? You would miss the signal in this case ?
>
> If my understanding is correct, kill() selects a random thread on a
> process for signal handling ; at least that's what pthreads(7) on Linux
> says:
>
> - POSIX.1 distinguishes the notions of signals that are directed to the
> process as a whole and signals that are directed to individual threads.
> According to POSIX.1, a process-directed signal (sent using kill(2),
> for example) should be handled by a single, arbitrarily selected thread
> within the process.

Exactly, in linux kernel, this is handle in kernel/
signal.c::complete_signal(), you might also have interest in wants_signal
() to see which kind of processes will be chosen by the kernel.

From: Rainer Weikusat on
WANG Cong <xiyou.wangcong(a)gmail.com> writes:
> On Thu, 29 Jul 2010 13:53:17 +0200, Xavier Roche wrote:
>> Ersek, Laszlo wrote:
>>> Or block SIGALRM in all other threads.
>>
>> What for ? You would miss the signal in this case ?
>>
>> If my understanding is correct, kill() selects a random thread on a
>> process for signal handling ; at least that's what pthreads(7) on Linux
>> says:

[...]

> Exactly, in linux kernel, this is handle in kernel/
> signal.c::complete_signal(), you might also have interest in wants_signal
> () to see which kind of processes will be chosen by the kernel.

That doesn't "select a random thead for signal handling" but walks
through all members of a particular thread group until a suitable one
has been found.