Edit report at https://bugs.php.net/bug.php?id=43627&edit=1
ID: 43627
Comment by: php at richardneill dot org
Reported by: user at example dot com
Summary: fopen blocks on fifo
Status: Bogus
Type: Bug
Package: Filesystem function related
Operating System: Debian Etch and RHEL 5
PHP Version: 5.2.5
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2008-01-29 00:15:50] [email protected]
man open
man 7 fifo
"Normally, opening the FIFO blocks until the other end is opened also."
------------------------------------------------------------------------
[2007-12-18 16:59:10] 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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=43627&edit=1