pthread_join() 可能导致什么信号

What signal might pthread_join() cause?

本文关键字:什么 信号 join pthread      更新时间:2023-10-16

我在C++中有一个错误条件,在调用 pthread_join() 时无法轻松重现一些信号,我不知道是哪一个,但我的信号处理程序被调用,并且由于某种原因没有打印出生成的信号的正常调试信息。我确实得到了一个堆栈跟踪,显示:

# 2 /lib/tls/libpthread.so.0: pthread_join(...) +0x1c [0xce439c]

我查看了 pthread_join() 的手册页,没有看到任何信号的提及。

可能产生的信号是什么,原因可能是什么? 这可能是某种竞争条件。

> http://linux.die.net/man/7/pthreads :

Signals are used in implementation internally

http://osr600doc.sco.com/man/html.PTHREAD/pthread_join.PTHREAD.html :

The wait in pthread_join is not broken by a signal.
If a thread waiting in pthread_join receives a signal that is not masked,
it will execute the signal handler, and then return to waiting in pthread_join.
Note that this behavior differs from that of pthread_cond_wait.

http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fapis%2Fusers_25.htm :

Threadsafe: Yes
Signal Safe: No

基本上,您可能会遇到pthread_join()由于某些错误或外部事件而接受其他信号的事实。

我们无法猜测究竟是什么导致了信号。

附言没有指定确切的环境,这使得决策更加困难。