|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-06-10 10:54 UTC] thomas dot wetzler at siemens dot com
Description:
------------
While sequentially opening and closing several processes via popen (or passthru, exec and '' command) php looses some processes. This takes place if, for instance, the user presses the reload-button on a website several times.
With the coding below, you can reproduce the failure (takes place on commandline (php.exe) and in apache module (mod_php)).
Reproduce code:
---------------
#!/wir/webadmin/share/php4/bin/php
#
<?
for ($i=0; $i<900; $i++) {
$statement = "ls -l";
echo "\n\n$i***************************\n";
$handle = popen($statement, 'r');
echo "Subprozess: '$handle'; " . gettype($handle) . "\n";
while (!feof($handle))
{
echo fread($handle, 8192);
}
pclose($handle);
}
?>
programcall: <progname> > <resultfile>
Expected result:
----------------
Within the result-file, there should be 900 times the same result from the system command (here ls -l command).
255***************************
Subprozess: 'Resource id #259'; resource
total 2526
-rw-r--r-- 1 webadmin oracle 572135 Jun 10 09:52 _test1.txt
drwxr-xr-x 2 wir oracle 96 May 2 15:27 mail
-rw-r--r-- 1 wir oracle 258956 Jun 10 10:42 test
-rwxrwx--- 1 wir oracle 698 Jun 10 10:41 test.php
-rw-r--r-- 1 webadmin oracle 105326 Jun 10 09:52 test1
-rwxrwx--- 1 wir oracle 656 Jun 10 09:48 test1.php
-rwxr-x--- 1 wir oracle 321 Jun 10 10:43 thomas.php
-rw-r--r-- 1 wir oracle 148274 Jun 10 10:43 thw.txt
Actual result:
--------------
Some results are missing. The same programm written in perl or shellscript is working correct.
-rwxr-x--- 1 wir oracle 321 Jun 10 10:43 thomas.php
-rw-r--r-- 1 wir oracle 148274 Jun 10 10:43 thw.txt
256***************************
Subprozess: 'Resource id #260'; resource
257***************************
Subprozess: 'Resource id #261'; resource
total 2526
-rw-r--r-- 1 webadmin oracle 572135 Jun 10 09:52 _test1.txt
drwxr-xr-x 2 wir oracle 96 May
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 03:00:01 2025 UTC |
Tested script from <thomas dot wetzler at siemens dot com> on php4.4.0 cli/apache2 and php4-STABLE-200507190640 on Linux server and ALL samples worked. Found this bug searching for a similar (maybe the same) issue related to popen/freads calling SVN. I modified this test script and ran tests using 4.4.0 and php4-STABLE-200507190640 with the following results: script ------ #!/usr/local/apache2/php/bin/php # <? for ($i=0; $i<10; $i++) { $statement = "/usr/local/subversion/bin/svn help"; echo "\n\n$i***************************\n"; $handle = popen($statement, 'r'); echo "Subprozess: '$handle'; " . gettype($handle) . "\n"; $output = ''; while (!feof($handle)) { $output .= fgets($handle); } echo $output; pclose($handle); } ?> results ------- /usr/local/apache2/php/bin/php -f test.php > test440_cli.txt > works wget -O test440_apache2.txt http://brainkrash.com/~screen/test/test.php > all 10 fail with no return from fgets /usr/local/apache2/php/bin/php -f test.php > test4-200507190640_cli.txt > works wget -O test4-200507190640_apache2.txt http://brainkrash.com/~screen/test/test.php > all 10 fail with no return from fgets expected result --------------- 0*************************** Subprozess: 'Resource id #4'; resource usage: svn <subcommand> [options] [args] Subversion command-line client, version 1.2.1. Type 'svn help <subcommand>' for help on a specific subcommand. Most subcommands take file and/or directory arguments, recursing on the directories. If no arguments are supplied to such a command, it recurses on the current directory (inclusive) by default. Available subcommands: add blame (praise, annotate, ann) ... <TRUNCATED> failure results --------------- 0*************************** Subprozess: 'Resource id #2'; resource <EOF>