Edit report at https://bugs.php.net/bug.php?id=60535&edit=1

 ID:                 60535
 User updated by:    andreas_nordal_4 at hotmail dot com
 Reported by:        andreas_nordal_4 at hotmail dot com
 Summary:            php ends prematurely when reading from pipe
 Status:             Open
 Type:               Bug
 Package:            *General Issues
 Operating System:   Windows 7 Enterprise SP1
 PHP Version:        5.3.8
 Block user comment: N
 Private report:     N

 New Comment:

I think I can reproduce bug 26271.

I had to modify the testcase, by setting the second argument of str_repeat 10 
times higher, and adding the suggested sleep.
I don't get a parse error, but the amount of sleep after proc_open determines 
the returnvalue of fwrite. If not sleeping, I always get 8192 no matter the 
argument to str_repeat.


Previous Comments:
------------------------------------------------------------------------
[2011-12-16 16:30:41] cataphr...@php.net

Maybe this is the same as bug #52911. Can you check it out? If so, this should 
be marked a duplicate.

------------------------------------------------------------------------
[2011-12-15 15:26:26] andreas_nordal_4 at hotmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=60535&edit=1

Reply via email to