Question

I have a system with 10+ threads. I have a signal handler to catch SIGSEGV. if one thread generates SIGSEGV, does that signal go to all threads, or just to the thread that generated the signal?

Was it helpful?

Solution

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top