I wanted t play around with the CGI (not CLI) version of PHP and get a feel for the I/O stuff, specifically STDIN. So I whipped up the following script:
/////////////////////////////////////////////////////////////////// #!/usr/bin/php -qC <? if( ($stdin = fopen( 'php://stdin', 'r' )) === false ) { echo 'Failed to open STDIN'."\n"; exit(); } stream_set_blocking( $stdin, false ); $count = 0; while( 1 ) { echo 'Foo: '.($count++)."\n"; if( ($char = fread( $stdin, 1 )) !== false ) { echo $char."\n"; } else { echo 'Fooo!'."\n"; } } //////////////////////////////////////////////////////////////////// Simple enough right?! The problem is the program exits seemingly randomly. The last value for $foo can be anywhere from 400 to 1500. Even more strange is that running it through gdb indicates a successful exit, with no problems or core dumps. Anyone had any similar experiences? I'm running PHP 4.3.3 (cgi) -- the latest download version. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php