|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
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.