Reputation: 361
The signal mask can be set on a per thread basis, but what about signal handles? If I call sigaction()
before creating new threads with pthread_create()
, will the new threads get the same signal handler? What if I use sigaction()
after pthread_create()
, will that change the entire process signal handlers or just the ones of the thread?
Upvotes: 0
Views: 144
Reputation: 25663
There is only ONE signal handler per process. So threads are not relevant in any kind here. The signal handler is called in the thread context which receives the signal. Which thread receives the signal is not specified if multiple threads have not blocked the signal.
You have to take care if multiple threads waits in system calls. Also you have to take care with using timer actions and calls to sleep.
You may also find this answer helpful: POSIX threads and signals
Upvotes: 2