C语言 EAGAIN 是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4058368/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 06:51:33  来源:igfitidea点击:

What does EAGAIN mean?

csocketsunixposix

提问by David van Dugteren

As in the title what does EAGAIN mean?

正如标题中的 EAGAIN 是什么意思?

回答by Frédéric Hamidi

EAGAINis often raised when performing non-blocking I/O. It means "there is no data available right now, try again later".

EAGAIN通常在执行非阻塞 I/O时引发。意思是“目前没有可用数据,稍后再试”

It might(or might not) be the same as EWOULDBLOCK, which means "your thread would have to block in order to do that".

可能(或可能不)与 相同EWOULDBLOCK,这意味着“您的线程必须阻塞才能做到这一点”

回答by turfx

Using man 2 intro | less -Ip EAGAIN:

使用man 2 intro | less -Ip EAGAIN

     35 EAGAIN Resource temporarily unavailable.  This is a temporary condi-
         tion and later calls to the same routine may complete normally.

回答by wildplasser

What it means is less important. What it implies:

这意味着什么并不重要。它的含义:

  • your system call failed
  • nothing happened (system calls are atomic, and this one just did not happen)
  • you couldtry it again (it could fail again, possibly with a different result)
  • or you couldchoose otherwise.
  • 你的系统调用失败
  • 什么也没发生(系统调用是原子的,而这个只是没有发生)
  • 可以再试一次(它可能会再次失败,可能会有不同的结果)
  • 或者你可以选择其他方式。

The whole thing about EAGAINis that your process is not blocked inside the system call; it has the right to choose: either retry or do something useful.

整件事EAGAIN是你的进程没有被系统调用阻塞;它有权选择:要么重试,要么做一些有用的事情。

回答by thelost

According to this, it means "Operation would have caused the process to be suspended."

根据这个,它的意思是“操作会导致进程暂停。”