我正在为嵌入式Linux系统编写用户应用程序,我正在使用常用功能,如open,close,read,ioctl等设备.现在,我读到了有关EINTR的信息,表明该功能被信号中断,但我不确定其含义.在我所有的示例程序中,有时它已完成,例如ioctl(),有时它没有完成,例如read().所以,我有点困惑.
我什么时候最好检查EINTR并重复功能调用?
Yan*_*aud 15
请参阅sigaction:http://pubs.opengroup.org/onlinepubs/009695399/functions/sigaction.html
SA_RESTART
This flag affects the behavior of interruptible functions; that is, those
specified to fail with errno set to EINTR. If set, and a function specified
as interruptible is interrupted by this signal, the function shall restart
and shall not fail with EINTR unless otherwise specified. If the flag is not
set, interruptible functions interrupted by this signal shall fail with errno
set to EINTR.
Run Code Online (Sandbox Code Playgroud)
默认情况下,您具有SA_RESTART行为,因此如果不使用信号,则不必担心EINTR.
| 归档时间: |
|
| 查看次数: |
29997 次 |
| 最近记录: |