ID:               25616
 User updated by:  robert at interjinn dot com
 Reported By:      robert at interjinn dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         Filesystem function related
 Operating System: Linux version 2.4.19-16mdk
 PHP Version:      4.3.3
 New Comment:

I just ran it with the -n flag and no change. Still exits seemingly
randomly :(


Previous Comments:
------------------------------------------------------------------------

[2003-09-21 02:44:21] [EMAIL PROTECTED]

Works fine for me..I let your script run for few minutes and it works
just as expected.

Try running it without any php.ini loaded, like this:

# php -n test.php

(-n will make PHP not load any php.ini)


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

[2003-09-21 01:08:41] robert at interjinn dot com

I have downloaded and compiled the PHP package located at

    http://snaps.php.net/php4-STABLE-latest.tar.gz

When I ran the script I got the same result as before. It still exits
successfully when it should be in an infinite loop.

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

[2003-09-20 17:46:37] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip



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

[2003-09-20 17:23:27] robert at interjinn dot com

Description:
------------
When I use stream_set_blocking() to make the standard input file handle
non-blocking the script exits seemingly random. For example the $count
output can have a last printed value anywhere from 200 to 3000.

Reproduce code:
---------------
<?
  
    if( ($stdin = fopen( 'php://stdin', 'r' )) === false )
    {                                                     
        echo 'Failed to open STDIN'."\n";
        exit();
    }          

    stream_set_blocking( $stdin, false );  
                                           
    $count = 0;                            
    while( 1 ) 
    {         
        echo 'Count: '.($count++)."\n";

        if( ($char = fread( $stdin, 1 )) != '' )
        {
            echo 'Char: '.$char."\n";
        }
        else
        {
            echo 'Fooo!'."\n";
        }
    }    


Expected result:
----------------
Script should run forever since it is in a while( 1 ) loop. This was
done on purpose for testing purposes. At each pass of the loop it
should print the current $count index, then if data exist in $stdin
then it should print the character, otherwise print Fooo! to the
screen.

Actual result:
--------------
Script does not run forever. Script exits and the last count printed
can be anywhere from 200 to 3000 -- it seems kind of random. I ran the
script through gdb and gdb indicates that the program (PHP) exits
properly. Thus there is no backtrace to provide.


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


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

Reply via email to