多线程信号处理
在unix中,如果向多线程进程发送信号,哪个线程将执行处理函数?
如果是多CPU机器,则同时运行的线程数超过1个。哪个线程将运行信号处理函数?
In unix, If a multi-threaded process was sent a signal, which thread will be the one to execute the handling function?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据man 7 signal,进程中的所有线程共享同一个信号处理程序,并且如果信号被传递到具有多个未阻塞该信号的线程的进程,任意选择其中一个线程来接收该信号。
拥有多 CPU 机器不会改变这些语义。
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.
Having a multi-CPU machine will not change these semantics.