Is php's fopen incompatible with the POSIX open for pipes

别说谁变了你拦得住时间么 提交于 2019-12-11 15:06:33

问题


Why is this so darn confusing. PHP's fopen will not open a file for reading unless there is data in the pipe waiting to be read (according to this comment). The POSIX specification for C's open states that, depending on the state of the O_NONBLOCK flag, when opening a pipe for writing, open will either block the calling process or return an error if no process has the file open for reading. Is this difference reconcilable?


回答1:


No. Php should signal C that it is expecting a connection and then block for input. C should loop while the open call returns -1 and errno == 6, and then fdopen the descriptor. Enjoy.



来源:https://stackoverflow.com/questions/4071865/is-phps-fopen-incompatible-with-the-posix-open-for-pipes

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