php 的 fopen 与 POSIX open for Pipes 不兼容吗

发布于 2024-09-30 07:55:31 字数 245 浏览 3 评论 0原文

为什么这如此令人困惑。 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一刻暧昧 2024-10-07 07:55:31

不。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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文