gpt4 book ai didi

linux - 段错误处理程序是线程安全的吗?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:11:24 27 4
gpt4 key购买 nike

当多线程应用程序在 Linux 上发生段错误并调用处理程序时,所有其他线程是否在调用处理程序之前立即停止?那么,依赖于在段错误处理期间不会执行任何并行代码这一事实是否合适?谢谢。

最佳答案

来自signal(7)手册页:

A signal may be generated (and thus pending) for a process as a whole (e.g., when sent using kill(2)) or for a specific thread (e.g., certain signals, such as SIGSEGV and SIGFPE, generated as a consequence of executing a specific machine-language instruction are thread directed, as are signals targeted at a specific thread using pthread_kill(3)). A process-directed signal may be delivered to any one of the threads that does not currently have the signal blocked. If more than one of the threads has the signal unblocked, then the kernel chooses an arbitrary thread to which to deliver the signal.

这一段说某些信号,比如SIGSEGV,是特定于线程的。哪个应该回答你的问题。

关于linux - 段错误处理程序是线程安全的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11938098/

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