Edit report at https://bugs.php.net/bug.php?id=60483&edit=1

 ID:                 60483
 Updated by:         cataphr...@php.net
 Reported by:        vmiszczak at ankama dot com
 Summary:            stream_select only selects STDIN if present in read
                     array
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Streams related
 Operating System:   Linux/Debian x64
 PHP Version:        5.3.8
 Block user comment: N
 Private report:     N

 New Comment:

This is just a timing issue. For instance, when I call sleep() after calling 
"$this->startPingPongProgram();", I get:

STDIN is blocking
Program STDIN is blocking
Program STDOUT is blocking
Program STDERR is blocking
We have 1 descriptor(s) ready :
Array
(
    [0] => Resource id #1
)
We have 1 descriptor(s) ready :
Array
(
    [0] => Resource id #1
)
We have 1 descriptor(s) ready :
Array
(
    [0] => Resource id #1
)
We have 2 descriptor(s) ready :
Array
(
    [0] => Resource id #5
    [1] => Resource id #1
)
We got data on Resource id #5 : !!! line 1
 !!!
!!! line 2
 !!!
!!! line 3
 !!!

line is false
Program's STDIN closed
Program's STDOUT closed
Program's STDERR closed
Program terminated

Which disproves your thesis. You'll have to coordinate the processes.

Thanks for the report, but I'm marking it bogus.


Previous Comments:
------------------------------------------------------------------------
[2011-12-12 12:59:25] vmiszczak at ankama dot com

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.

------------------------------------------------------------------------
[2011-12-11 15:52:23] cataphr...@php.net

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

Reply via email to