gpt4 book ai didi

linux - Tun fd 上的 read(2) 返回零

转载 作者:太空宇宙 更新时间:2023-11-04 04:53:11 26 4
gpt4 key购买 nike

在我的应用程序中,创建了一个 Tun 接口(interface),并且该进程在 select(2) 循环中继续使用 read(2) 读取关联的 fd。但是,当我调试应用程序中的问题时,我发现在某些时候对 Tun 文件描述符的 read(2) 操作可能会返回零。这可能吗?发生的条件是什么?

提前致谢。木香

最佳答案

以下是有关 read(2) click here 的联机帮助页中的信息

Return Value

On success, the number of bytes read is returned (zero indicates end of file), and the file position is advanced by this number. It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now (maybe because we were close to end-of-file, or because we are reading from a pipe, or from a terminal), or because read() was interrupted by a signal. On error, -1 is returned, and errno is set appropriately. In this case it is left unspecified whether the file position (if any) changes.

关于linux - Tun fd 上的 read(2) 返回零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53439835/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com