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.