From:             poehler at interworx dot com
Operating system: CentOS 5.4
PHP version:      5.2.13
PHP Bug Type:     *General Issues
Bug description:  Exec family of functions runs a script piped into 'head' too 
until script end

Description:
------------
See reproduce code and expected / actual result sections for details.

Short story is when exec'ing with a pipe to 'head', we're getting
unexpected results.

I'm aware this may be 'correct' behavior, by some definition, but for the
life of me I can't figure out where this behavior is documented, if that is
the case.  So if that is the case, please point me in the right direction,
if you could be so kind.



Reproduce code:
---------------
test.sh:
=================
#!/bin/sh

for i in 1 2 3 4 5
do
   echo "Welcome $i times"
   sleep 1
done
==================


test.php:
==================
<?
passthru( '/bin/sh test.sh | head -n1' );

==================




Expected result:
----------------
Here is the output of running the same command at the shell, which is
correct.
==================
[r...@me]# time /bin/sh test.sh | head -n1
Welcome 1 times

real    0m1.030s
user    0m0.002s
sys     0m0.027s
==================
And I would expect identical (save minor timing differences) when test.php
is run.

Actual result:
--------------
[r...@me]# php test.php
Welcome 1 times
test.sh: line 5: echo: write error: Broken pipe
test.sh: line 5: echo: write error: Broken pipe
test.sh: line 5: echo: write error: Broken pipe
test.sh: line 5: echo: write error: Broken pipe

real    0m5.191s
user    0m0.002s
sys     0m0.038s

Note that this took 5 seconds instead of 1.

-- 
Edit bug report at http://bugs.php.net/?id=51160&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=51160&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=51160&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=51160&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=51160&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51160&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=51160&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=51160&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=51160&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=51160&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=51160&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=51160&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=51160&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=51160&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=51160&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51160&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51160&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=51160&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=51160&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=51160&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=51160&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=51160&r=mysqlcfg

Reply via email to