do threads in the process share the signal handler?
Hi
I am studying the Advanced Programming in the Unix Environment these days. When I come to the chapter of Threads and signals, I find it difficult for me to understand the statement that the signal disposition is shared by all threads in the process. Dose it mean that threads in the same process share the signal handler or just the attributes that set by sigaction ? I will appreciate your helping me. |
It's true that signals are sent to the (overall) process (pid); you can't send a signal to an individual thrd, so you need to be real careful and ideally minimize the amt of code in a sig handler routine.
Best to just set a flag for the normal code to deal with and leave it at that. One exception I've used is to use SIGHUP to re-read the cfg file. Apache does the same. Also, you might want to ask the mods to move this to the Programming forum (use the Report button) |
Quote:
From my understanding, If a nonblocking signal is sent to a process,every thread in the processs will do the same thing.Because the threads share the the signal handler. Is that right? I new here.This my first post in this forum.I do not know how to move my post to programming. |
Quote:
|
Quote:
|
@fmurphy: indeed, but from that same page:
Quote:
kill -SIGHUP <pid of process> cannot be specified to target a given thread; it's delivered to the process as a whole and the actual thread that will first respond is undefined. |
All times are GMT -5. The time now is 07:13 PM. |