php的fopen是否与POSIX开放管道不兼容 [英] Is php's fopen incompatible with the POSIX open for pipes

查看:116
本文介绍了php的fopen是否与POSIX开放管道不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这为什么如此令人困惑. 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屋!

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