From: fmuller at cisco dot com
Operating system: Red Hat 7.3.1
PHP version: 4.3.3
PHP Bug Type: Program Execution
Bug description: ping of a non responding host hangs when run from php invoked from
apache
Description:
------------
The -w [deadline] argument to Red Hat's ping command doesn't work when
apache runs a php page that invokes the ping command that attempts to ping
an unreachable host.
The ping command works fine(it times out) when I run the php script from
the command line, and if I run a similiar perl cgi, but the ping command
doesn't timeout, so the php script hangs when invoked via apache.
I'm hoping that some how apache/php disables the mechanism the ping
command uses to time it's self out, and that there is a work around, or a
fix.
Reproduce code:
---------------
<?
print "<plaintext>\n";
$hosts[] = "127.0.0.1";
$hosts[] = "good address";
$hosts[] = "bad address";
foreach ( $hosts as $host ) {
$cmd = "/bin/ping -c2 -w2 -q '$host'"; # Red Hat
print "$cmd\n";
$ph = popen($cmd,"r");
while ( $line = fgets($ph,2048) ) {
}
$status = pclose($ph);
if ( $status == 0 ) {
print "$host: SUCCESS($status)\n";
}
else {
print "$host: FAIL($status)\n";
}
}
?>
Expected result:
----------------
When run from commandline:
<plaintext>
/bin/ping -c2 -w2 -q '127.0.0.1'
127.0.0.1: SUCCESS(0)
/bin/ping -c2 -w2 -q 'good address'
64.102.40.165: SUCCESS(0)
/bin/ping -c2 -w2 -q 'bad address'
64.102.40.167: FAIL(1)
I'd expect the same thing when run from apache
Actual result:
--------------
When run from apache:
I process associated with the ping hangs and needs to
be killed.
--
Edit bug report at http://bugs.php.net/?id=26648&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26648&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26648&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26648&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26648&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26648&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=26648&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=26648&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26648&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26648&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26648&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26648&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26648&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26648&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26648&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26648&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26648&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26648&r=float