I have a system with 10+ threads. I have a signal handler to catch SIGSEGV. if one t开发者_运维知识库hread generates SIGSEGV, does that signal go to all threads, or just to the thread that generated the signal?
SIGSEGV
is a synchronous signal. It'll be delivered to the thread that caused the invalid memory access. From signal(7)
:
A signal may be generated (and thus pending) for a process as a whole (e.g., when sent usingkill(2)
) or for a specific thread (e.g., certain signals, such asSIGSEGV
andSIGFPE
, generated as a consequence of executing a specific machine-language instruction are thread directed, as are signals targeted at a specific thread usingpthread_kill(3)
). A process-directed signal may be delivered to any one of the threads that does not currently have the signal blocked. If more than one of the threads has the signal unblocked, then the kernel chooses an arbitrary thread to which to deliver the signal.
精彩评论