From: hanskrentel at yahoo dot de Operating system: windows PHP version: 5.4.13 Package: Filesystem function related Bug Type: Bug Bug description:proc_open hangs with stdin/out with 4097+ bytes
Description: ------------ The stream used to read data from stdin/out/err hangs if the data passed is getting larger than 4096 (taht is 4097 and above), always. Test script: --------------- error_reporting(E_ALL); $cmd = 'php -r "fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);"'; $descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w')); $stdin = str_repeat('*', 4097); $options = array_merge(array('suppress_errors' => true, 'binary_pipes' => true, 'bypass_shell' => false)); $process = proc_open($cmd, $descriptors, $pipes, getcwd(), array(), $options); foreach ($pipes as $pipe) { stream_set_blocking($pipe, false); } $writePipes = array($pipes[0]); $stdinLen = strlen($stdin); $stdinOffset = 0; unset($pipes[0]); while ($pipes || $writePipes) { $r = $pipes; $w = $writePipes; $e = null; $n = stream_select($r, $w, $e, 60); if (false === $n) { break; } elseif ($n === 0) { proc_terminate($process); } if ($w) { $written = fwrite($writePipes[0], (binary)substr($stdin, $stdinOffset), 8192); if (false !== $written) { $stdinOffset += $written; } if ($stdinOffset >= $stdinLen) { fclose($writePipes[0]); $writePipes = null; } } foreach ($r as $pipe) { $type = array_search($pipe, $pipes); $data = fread($pipe, 8192); if (false === $data || feof($pipe)) { fclose($pipe); unset($pipes[$type]); } } } Expected result: ---------------- Process executes in a fraction of a second and finishes with exit code 0 Actual result: -------------- Process executes and hangs. -- Edit bug report at https://bugs.php.net/bug.php?id=64438&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64438&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64438&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64438&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64438&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64438&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64438&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64438&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64438&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64438&r=support Expected behavior: https://bugs.php.net/fix.php?id=64438&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64438&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64438&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64438&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64438&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64438&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64438&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64438&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64438&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64438&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64438&r=mysqlcfg