From: Operating system: Windows 7 Enterprise SP1 PHP version: 5.3.8 Package: *General Issues Bug Type: Bug Bug description:php ends prematurely when reading from pipe
Description: ------------ I am using the command-line `php` program in a bash script to generate a html file, like so: # stage 1: intermediate="$(php doc.php)" # stage 2: echo "$intermediate" | php > doc.html Stage 2 doesn't work on Windows when doc.html gets big (observed sizes in bytes: 42033, 42079, 41989, 42856, 41924). Php just ends prematurely, without printing any error message to either standard error or out. The size of doc.html is consistent every time I try, but depends on, at least, the amount of static content (between ?> an, d <?) in $intermediate. The output always ends on a linefeed. I also tried piping a pure html file of size 32597 (https://bugs.php.net/report.php) through php in similar fashion. This time, the output size was inconsistent. Mostly, it was truncated to 16423, sometimes not truncated, and once truncated to 8945. Absurdly, this workaround works: echo "$intermediate" | tee intermediate.php; cat intermediate.php | php > doc.html The fact that tee is able to read everything from the same pipe, and php succeeds when its input comes from cat, makes me think this is php's fault (likely a timing issue) rather than bash. Of course, I might be wrong. The same bash script works flawlessly on Linux. I have php version 5.3.8 both on Linux and Windows. The installer I used on Windows is named "php-5.3.8-Win32-VC9-x86.msi", has filesize 40300544 and md5sum 2eacd59df8d6b46d5538f2935514d77b. This bug might explain bug 26271 (which deals with named pipes): In his case, I can imagine that the writer would hang if the reader ends prematurely. Just speculating. -- Edit bug report at https://bugs.php.net/bug.php?id=60535&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60535&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60535&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60535&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60535&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60535&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60535&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60535&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60535&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60535&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60535&r=support Expected behavior: https://bugs.php.net/fix.php?id=60535&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60535&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60535&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60535&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60535&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60535&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60535&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60535&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60535&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60535&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60535&r=mysqlcfg