BЈо*_*вић 2 c c++ linux select blocking
select()的手册页没有列出EAGAIN作为select()函数的可能错误代码。
谁能解释在哪种情况下select()会产生EAGAIN错误?
如果我了解select_tut手册页,则可以通过向被阻塞的进程发送信号,等待阻塞的select()来产生EAGAIN。它是否正确?
由于我在具有超时的阻止模式下使用select(),如下所示:
bool selectRepeat = true;
int res = 0;
timeval selectTimeout( timeout );
while ( true == selectRepeat )
{
res = ::select( fd.Get() + 1,
NULL,
&writeFdSet,
NULL,
&selectTimeout );
selectRepeat = ( ( -1 == res ) && ( EINTR == errno ) );
}
Run Code Online (Sandbox Code Playgroud)
错误号为EAGAIN时,我应该重复循环吗?
select()EAGAIN在任何情况下均不会返回。但是,EINTR如果被信号中断,它可能会返回(这适用于大多数系统调用)。
EAGAIN(或者EWOULDBLOCK)可以从被返回read,write,recv,send,等。