php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26648 ping of a non responding host hangs when run from php invoked from apache
Submitted: 2003-12-17 10:07 UTC Modified: 2003-12-18 03:12 UTC
From: fmuller at cisco dot com Assigned:
Status: Not a bug Package: Program Execution
PHP Version: 4.3.3 OS: Red Hat 7.3.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fmuller at cisco dot com
New email:
PHP Version: OS:

 

 [2003-12-17 10:07 UTC] 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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-18 03:12 UTC] sniper@php.net
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.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 18:01:34 2025 UTC