php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43627 fopen blocks on fifo
Submitted: 2007-12-18 16:59 UTC Modified: 2008-01-29 00:15 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: user at example dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.5 OS: Debian Etch and RHEL 5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: user at example dot com
New email:
PHP Version: OS:

 

 [2007-12-18 16:59 UTC] user at example dot com
Description:
------------
fopen() blocks waiting for read on named pipes (FIFOs) opened for reading.

Reproduce code:
---------------
At Unix prompt:
% mkfifo myfifo

PHP:
$fp = fopen('myfifo', 'r');

Expected result:
----------------
PHP execution should continue until attempting to read from the FIFO, e.g.:

 fread($fp, 1);

Actual result:
--------------
PHP execution suspends (blocks) on the fopen() command until another process writes data to the FIFO.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-29 00:15 UTC] tony2001@php.net
man open
man 7 fifo

"Normally, opening the FIFO blocks until the other end is opened also."
 [2011-08-01 16:30 UTC] php at richardneill dot org
Similarly, fopen blocks if the fifo is opened for writing, and the "other side" isn't being read yet:  $fp = fopen('myfifo', 'w');
I'd expect the fwrite() to block, but not the fopen().

Linux's man fifo says that this is the default behaviour, but that it is possible to make it non-blocking. This would be useful, because we can't call stream_select() to find out whether writes would block until we have fopen()'d the pipe, but fopen() blocks. There is no way to test in advance whether fopen() would block, because most cases don't expect it to.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 07:01:28 2024 UTC