Edit report at https://bugs.php.net/bug.php?id=60483&edit=1
ID: 60483
User updated by: vmiszczak at ankama dot com
Reported by: vmiszczak at ankama dot com
Summary: stream_select only selects STDIN if present in read
array
-Status: Feedback
+Status: Open
Type: Bug
Package: Streams related
Operating System: Linux/Debian x64
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
Here is a simple dummy.php that can be used as a program opened with
proc_open()
:
http://pastebin.com/78KEpbBB
Here is a way to show the problem :
http://pastebin.com/aNZK6DBv
If you launch this script simply using "php bug.php" and sending data by hand,
no problem, it will do the job.
If you launch this script using "php bug.php < lines.txt" where lines.txt is a
text file containing lines, the response from the proc_opened process happens
only when there is no more data on STDIN. That's not nice because I want to
create a real time forwarder.
I may have missed something with the buffering system but it looks like a
problem.
Previous Comments:
------------------------------------------------------------------------
[2011-12-11 15:52:23] [email protected]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2011-12-09 15:25:29] vmiszczak at ankama dot com
Description:
------------
I'm writing a data multiplexer PHP CLI script that takes data from STDIN and
dispatchs
those data on programs opened with proc_open().
I'm using stream_select() to see which descriptor has data. The read array I'm
using contains STDIN and the output streams from programs opened with
proc_open()
(the classic $pipes[1] from proc_open() descriptorspec). Those programs write
on
their stdout as soon as there is data on their stdin (actually those programs
are
PHP scripts echoing input). If STDIN remains in the read set, stream_select
returns only STDIN as readable and never returns any of the programs output
streams.
As soon as STDIN is removed from the read set, stream_select behave normaly and
selects the output streams that are ready.
Expected result:
----------------
I'm expecting all my ready streams to be returned, even if STDIN is present in
the
set.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60483&edit=1