本文介绍了在阻止模式返回选择()在管道EAGAIN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

借助没有列出EAGAIN尽可能错误code为select()函数。

The man pages for select() do not list EAGAIN as possible error code for the select() function.

任何人都可以解释什么情况下选择()会产生EAGAIN错误?

Can anyone explain in which cases the select() can produce EAGAIN error?

如果我的理解,EAGAIN可以通过发送信号产生这是阻塞等待受阻选择()的过程。这是正确的?

If I understand select_tut man page, EAGAIN can be produced by sending a signal to the process which is blocked waiting on blocked select(). Is this correct?

由于我使用select()与超时阻塞模式,是这样的:

Since I am using select() in blocking mode with timeout, like this:

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 ) );
}

我应该只是重复时错误码EAGAIN循环?

should I just repeat the loop when the error number is EAGAIN?

推荐答案

选择()将不会返回 EAGAIN 在任何情况下。
它可能,但是,如果返回由信号(这适用于大多数系统调用)中断 EINTR

select() will not return EAGAIN under any circumstance.It may, however, return EINTR if interrupted by a signal (This applies to most system calls).

EAGAIN (或 EWOULDBLOCK )可以从回读的recv 发送等。

EAGAIN (or EWOULDBLOCK) may be returned from read, write, recv, send, etc.

这篇关于在阻止模式返回选择()在管道EAGAIN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 08:31