Bug #69049 [NEW]: Unable to get output of slow process

From: Date: Fri, 13 Feb 2015 05:44:26 +0000
Subject: Bug #69049 [NEW]: Unable to get output of slow process
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190646@lists.php.net to get a copy of this message
From: aserbulov at parallels dot com Operating system: Windows PHP version: 5.5.21 Package: Streams related Bug Type: Bug Bug description:Unable to get output of slow process Description: ------------ If you use proc_open to open slow process (it should write to stdout not immediately, but after some time), you never get process output. Slow process emulation: --- <?php sleep(60); // Do some work fwrite(STDOUT, 'done'); exit(0); --- It is side effect of bug https://bugs.php.net/bug.php?id=51800 fix. Test script: --------------- $cmd = "\"C:/Program Files/php/php.exe\" process.php"; $status; $stdout = ""; $pipes = []; $descriptors = [ 0 => ["pipe", "r"], // stdin 1 => ["pipe", "w"], // stdout 2 => ["pipe", "w"], // stderr ]; $process = proc_open($cmd, $descriptors, $pipes); fclose($pipes[0]); fclose($pipes[2]); while (!feof($pipes[1])) $stdout .= fread($pipes[1], 1024); fclose($pipes[1]); $status = proc_close($process); print_r(["status" => $status, "stdout" => $stdout]); Expected result: ---------------- 1. fread() function should read the pipe until the desired number of bytes has been read or reaches the end of the pipe. 2. feof() function should return true if fread() function reaches the end of the pipe. Actual result: -------------- 1. fread() return empty string 2. feof($pipes[1]) return true after ~36 seconds. -- Edit bug report at https://bugs.php.net/bug.php?id=69049&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69049&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69049&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69049&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69049&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69049&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69049&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69049&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69049&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69049&r=support Expected behavior: https://bugs.php.net/fix.php?id=69049&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69049&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69049&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69049&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69049&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69049&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69049&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69049&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69049&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69049&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69049&r=mysqlcfg

« previous php.bugs (#190646) next »