php的fopen是否与POSIX开放管道不兼容 [英] Is php's fopen incompatible with the POSIX open for pipes
问题描述
这为什么如此令人困惑. PHP的fopen不会打开文件进行读取,除非管道中有等待读取的数据(根据此评论). C的OPEN的POSIX规范指出,根据O_NONBLOCK标志的状态,在打开要写入的管道时,open会阻止调用进程,或者如果没有进程打开要读取的文件,则将返回错误.这种差异可以调和吗?
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?
推荐答案
否. Php应向C发出信号,表明它正在等待连接,然后阻止输入. C应该在open调用返回-1并且errno == 6时循环,然后fdopen描述符.享受.
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.
这篇关于php的fopen是否与POSIX开放管道不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!