What is select supposed to do if you close a monitored fd?

我的梦境 提交于 2020-01-01 17:06:30

问题


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?


回答1:


From the description of select in "The Open Group Base Specifications Issue 7":

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.



来源:https://stackoverflow.com/questions/3884110/what-is-select-supposed-to-do-if-you-close-a-monitored-fd

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!