#26648 [Opn->Bgs]: ping of a non responding host hangs when run from php invoked from apache
| From: | sniper@php.net | Date: | Thu, 18 Dec 2003 08:12:06 +0000 |
| Subject: | #26648 [Opn->Bgs]: ping of a non responding host hangs when run from php invoked from apache | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-52242@lists.php.net to get a copy of this message | ||
ID: 26648
Updated by: sniper@php.net
Reported By: fmuller at cisco dot com
-Status: Open
+Status: Bogus
Bug Type: Program Execution
Operating System: Red Hat 7.3.1
PHP Version: 4.3.3
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
Not PHP bug.
Previous Comments:
------------------------------------------------------------------------
[2003-12-17 10:07:15] fmuller at cisco dot com
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 this bug report at http://bugs.php.net/?id=26648&edit=1