如果关闭受监控的FD,应该怎么办? [英] What is select supposed to do if you close a monitored fd?

查看:111
本文介绍了如果关闭受监控的FD,应该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以对此进行测试以找到其行为,但这不是重点.在我对另一个问题的回答中,评论者建议关闭一个从另一个线程监视fd来唤醒select.另一位评论者在标准中找不到对此行为的引用,我也找不到.

I can test this to find the behavior but that's not the point. In my answer to another question, a commenter recommended closing a monitored fd from another thread to wake up select. Another commenter couldn't find a reference to this behavior in the standard, and I can't find one either.

有人可以提供有关此行为的标准的指针吗?

Can someone provide a pointer to the standard on this behavior?

推荐答案

摘录自:

当对O_NONBLOCK清除的输入函数的调用不会阻塞时,无论该函数是否将成功传输数据,都应认为描述符已准备就绪,可以读取. (该函数可能会返回数据,文件结尾指示或一个错误,表明该文件已被阻止,并且在每种情况下,描述符都应被视为可以读取.)

A descriptor shall be considered ready for reading when a call to an input function with O_NONBLOCK clear would not block, whether or not the function would transfer data successfully. (The function might return data, an end-of-file indication, or an error other than one indicating that it is blocked, and in each of these cases the descriptor shall be considered ready for reading.)

所以,我想说这种方法是可移植的.

So, I would say this method is portable.

这篇关于如果关闭受监控的FD,应该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆