gpt4 book ai didi

linux - pthread_kill 不仅杀死一个线程而且杀死整个程序

转载 作者:太空宇宙 更新时间:2023-11-04 10:42:57 27 4
gpt4 key购买 nike

我正在使用 int s=pthread_kill(thread_arr[t], 9); 将 SIGKILL 信号发送到位于 thread_arr t 位置的线程,而不是杀死这个确切的线程我的整个程序都被杀死了。如果我做错了什么,谁能告诉我?

最佳答案

我认为答案在 pthread_kill 的手册页中:

Signal dispositions are process-wide: if a signal handler is installed, the handler will be invoked in the thread, but if the disposition of the signal is "stop", "continue", or "terminate", this action will affect the whole process.

SIGKILL的处理是终止进程,信号不能被捕获、阻塞或忽略。

我建议使用不同的信号,并让接收信号的线程自行停止,而不是使用

关于linux - pthread_kill 不仅杀死一个线程而且杀死整个程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34258271/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com