据我所知,linux/unix 上的大多数系统调用在收到信号时都会中断。根据下面的博文,有一些系统调用没有被中断:
In general function that return immediately (don't wait for any I/O operation to complete or sleep) are not interruptible like socket(2) which just allocates a socket and doesn't wait for anything.
http://www.linuxprogrammingblog.com/all-about-linux-signals?page=5
是否有这些函数的列表?任何与此主题相关的链接都会有所帮助。
最佳答案
What is the mechanism that kernel uses to decide which call is interruptible and which one is not? (if the story with "socket()" is true)
任务有位掩码,可以用set_task_state设置到 TASK_INTERRUPTIBLE
和 TASK_UNINTERRUPTIBLE
(定义 here)。
Is there a list of those kind of functions?
我不认为存在不间断函数列表。您可以搜索 TASK_UNINTERRUPTIBLE
的用法(例如 this)
编辑:example用 signal_pending_state 检查这个标志
关于linux - 哪些系统调用不会被信号中断?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35085178/