which running thread gests the external signal

Daniel Eischen deischen at freebsd.org
Tue May 2 00:52:04 UTC 2006

On Tue, 2 May 2006, Alin-Adrian Anton wrote:

> Hi Hackers,
> 	I'm working on a threaded daemon and I'm trying to make it sysadmin 
> friendly. For this, I'm working with external signals.
> 	I noticed different behaviour between BSD and Linux for this. When I 
> send an external SIGHUP (rehashing the config file) on BSD the thread 
> receiving the signal seems to be "random".

POSIX states any thread that is in sigwait() (with the specified
signal in the wait mask), or has the signal unmasked (in the threads
signal mask) can receive the signal.  If you want a certain thread
to receive a process-wide signal, then the only sure way (POSIX) to
do that is to block the signal in all the threads with the exception
of the thread that is to receive the signal.

> On Linux, if I remeber well, all 
> the threads get the signal, sooner or later.. (the signal handler gets 
> executed as many times as the number of running threads)

Then Linux is wrong.  I don't think that is the case any longer,
but may have been with there older LinuxThreads model.

> 	The tests I've done were done some time ago, this is why I must 
> appologise if I get the chance to mix the memories :|.
> 	So just in case anyone already knows (on BSD): which thread gets 
> stopped and moves execution to the signal handler function, when the signal 
> is sent by kill(1) to the pid of the daemon, which is the same for all the 
> threads? (sorry if dizzy speaking)

See above.

> 	And also, is there a way for delegating one special thread to handle 
> all the external signals? (on BSD)

See above.

> 	Thanks for the time guys.

I would recommend you also visit



More information about the freebsd-hackers mailing list