我正在为一个嵌入式Linux系统编写一个用户应用程序,我正在为这些设备使用诸如打开、关闭、读取、ioctl等常见功能.现在,我读到了关于EINTR的文章,指出函数被信号中断,但我不确定其含义.在我所有的示 routine 序中,有时完成了,例如ioctl(),有时没有完成,例如read().所以,我有点困惑.
我最好什么时候判断EINTR并重复函数调用?
我正在为一个嵌入式Linux系统编写一个用户应用程序,我正在为这些设备使用诸如打开、关闭、读取、ioctl等常见功能.现在,我读到了关于EINTR的文章,指出函数被信号中断,但我不确定其含义.在我所有的示 routine 序中,有时完成了,例如ioctl(),有时没有完成,例如read().所以,我有点困惑.
我最好什么时候判断EINTR并重复函数调用?
见行动: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.
默认情况下,您有sau重启行为,因此如果不使用信号,就不必担心EINTR.