如果没有线程阻塞信号,并且有一个线程处于"sigwait()"中,是否可以保证被阻塞的线程将接收下一

If no threads are blocking a signal, and one thread is in `sigwait()`, is there any guarantee that the blocked thread will receive the next signal?

本文关键字:线程 quot sigwait 有一个 信号 如果没有 是否      更新时间:2023-10-16

假设我有一个不阻塞任何信号的多线程应用程序,并且一个线程调用sigwait()并为SIGTERM提供掩码。如果进程从外部接收到SIGTERM,是否保证以下任一项?

  1. sigwait()上被阻止的线程将接收它
  2. 上面的线程是将接收它的唯一线程

我查看了手册页,但它没有解决这两个问题。

至少对于Linux:这两种可能性都不能保证,如:

来自man 7 signal:

信号处理是每个进程的属性:在多线程应用程序中,特定信号的处理对所有线程都是相同的。

因此,由于多个线程没有阻止SIGINT,这些线程可能会收到它。