问题描述
-
在Unix中,如果发送了一个多线程进程信号,那么哪个线程将是执行处理功能的线程?
In unix, If a multi-threaded process was sent a signal, which thread will be the one to execute the handling function?
如果它是多CPU计算机,则同时运行多个线程.将在哪个线程上运行信号处理功能?
if it is a multi-cpu machine, more than 1 thread is running at the same time. which thread will be the on to run the signal handling function?
推荐答案
根据 man 7 signal ,该进程中的所有线程共享同一个信号处理程序,并且如果将信号传递给具有多个没有阻塞该信号的线程的进程,则可以任意选择其中之一来接收该信号.
According to man 7 signal, all threads in the process share the same signal handler, and if a signal is delivered to a process with multiple threads that have not blocked the signal, one of them is arbitrarily chosen to receive it.
拥有多CPU机器不会更改这些语义.
Having a multi-CPU machine will not change these semantics.
这篇关于多线程信号处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!