Q: Thread and system signals I'm programing a multithreaded program that needs to intercept system signals (such as SIGINT). I would like to know if there is a normalized way to "catch" these signals like:


*

*A Signal is sent, may any thread receive it or only the main() one ?

*Is there a Posix rule or a programming idiom that specifies how to handle this ? 


A: It is guaranteed that precisely one thread receives the signal, but it is also unspecified which thread that is.
The proper thing to do is to block signals on all threads but one, so that that thread alone deals with signal handling; or on Linux specifically block threads everywhere and set up a signalfd to catch signals — that way, you don't introduce any asynchronousity and signals become just one more file descriptor to read from.

A: Since you asked about POSIX, from man signal(7)

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.

So in short, it means a random thread will be chosen to handle the signal.
