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

 ID:                 62697
 Comment by:         brandon dot landry at dvusd dot org
 Reported by:        brandon dot landry at dvusd dot org
 Summary:            stream_get_line hangs
 Status:             Feedback
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   suse
 PHP Version:        5.3.15
 Block user comment: N
 Private report:     N

 New Comment:

I apologize, the script does not hang (that was the effect in the production 
code I extracted this snipit from) , this script simply does not return the 
correct data.  I copied the test script i submitted into test.php and ran these 
2 tests on a sles linux 11.2 install.
Here is the result of the tests:

webdevel@DVP-VM src $ php ./test.php
array (
  'streamSelect_returnVal' => 1,
  'stdout_strRead' => '/tmp
',
)webdevel@DVP-VM src $ vi test.php
webdevel@DVP-VM src $ # changed fgets to stream_get_line
webdevel@DVP-VM src $ php ./test.php
array (
  'streamSelect_returnVal' => 1,
  'stdout_strRead' => false,
webdevel@DVP-VM src $ cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
webdevel@DVP-VM src $ uname -a
Linux DVP-VM 3.0.34-0.7-default #1 SMP Tue Jun 19 09:56:30 UTC 2012 (fbfc70c) 
x86_64 x86_64 x86_64 GNU/Linux

I've tried on openSuse and Novell's Suse with the same results, unfortunately 
we're tied to suse for our environment here, but I could try installing an 
ubuntu vm for testing if required.


Previous Comments:
------------------------------------------------------------------------
[2012-07-31 15:27:26] larue...@php.net

I can not reproduce this on linux, (after replace the stream_get_line to fgets);


could you please provide a reproducable script?

------------------------------------------------------------------------
[2012-07-30 15:57:01] brandon dot landry at dvusd dot org

Description:
------------
In php 5.3.11 there was some change made to stream_get_line which causes this 
test 
script to hang (it still hangs on the latest version from 5.3 and 5.4 
branches).  
In  the changelog for that version it says stream_get_line was changed to be 
more 
in line with fgets ... Now if you replace stream_get_line with fgets the script 
does run seemingly correctly ... The only reason I am reporting this is, if the 
function was changed to be more in line with fgets, and fgets works but 
stream_get_line does not, ... is this a bug or something I am missing.


Test script:
---------------
<?php

$descSpec = array(
    array('pipe','r'),  // stdin
    array('pipe','w'),  // stdout
    array('pipe','w')   // stderr
);
$proc = proc_open('bash', $descSpec, $pipes,'/tmp',array());
if(!is_resource($proc)){
    throw new Exception("Could not open bash process");
}
$stdin  = &$pipes[0];
$stdout = &$pipes[1];
$stderr = &$pipes[2];

stream_set_blocking($stdout,0);
stream_set_blocking($stderr,0);

fwrite($stdin, "pwd\n");
fflush($stdin);

$write = null;
$except = null;
$stdoutArr  = array($stdout);
$rv = stream_select($stdoutArr,$write,$except,1);
$strIn = stream_get_line($stdout,4096);
var_export(array('streamSelect_returnVal'=>$rv,'stdout_strRead'=>$strIn));



------------------------------------------------------------------------



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

Reply via email to