开发者

POSIX Threads and SIGSEGV

开发者 https://www.devze.com 2023-01-31 06:06 出处:网络
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 t

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 using kill(2)) or for a specific thread (e.g., certain signals, such as SIGSEGV and SIGFPE, generated as a consequence of executing a specific machine-language instruction are thread directed, as are signals targeted at a specific thread using pthread_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.
0

精彩评论

暂无评论...
验证码 换一张
取 消