Bug #15941 [Opn]: exec() never returns when pinging firewalled host
| From: | craig at constantine dot name | Date: | Mon, 02 Mar 2009 14:15:52 +0000 |
| Subject: | Bug #15941 [Opn]: exec() never returns when pinging firewalled host | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-104@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=15941&edit=1
ID: 15941
Updated by: craig@constantine.name
Reported By: babineau at gmail dot com
Summary: exec() never returns when pinging firewalled host
Status: Open
Type: Bug
Package: Net_Ping
Operating System: Linux (Gentoo)
PHP Version: 5.2.8
Roadmap Versions:
New Comment:
Maybe there's something specific with the system Steve is using?? I
vaguely recall being able to tell the shell to trap and ignore signals.
Maybe
something unusual is configured with the web server's environment?
Steve, do you know how to use the PCNTL extension in PHP? Can you try a
quick PHP script to set a SIGALRM and see if PHP can schedule and
receive
signals?
Previous Comments:
------------------------------------------------------------------------
[2009-03-01 22:32:59] doconnor
Steve, the not-receiving-from-kernel sounds a bit out of the hands of
Net_Ping - I don't suppose you can find an existing bug report somewhere
upstream and link these two together?
------------------------------------------------------------------------
[2009-02-25 23:34:47] babineau
Here's a little more debug info. It looks like ping running from
exec() never receives a SIGARLM from the kernel. I wonder if there is a
workaround that can be built into Net_Ping?
http://shifteightgeneration.com/tmp/strace.from.commandline.gz
http://shifteightgeneration.com/tmp/strace.from.php.gz
------------------------------------------------------------------------
[2009-02-25 15:37:38] babineau
Sure. Here's the State flag info (-j didn't work, but BSD ps does it
anyway)
$ ps ax |grep ping
26810 ? S 0:00 sh -c cd '/prj/htdocs/net' ; /bin/ping -c 4
-t 60 microsoft.com
26811 ? S 0:00 /bin/ping -c 4 -t 60 microsoft.com
checkHost() hangs as well.
# $ping->checkHost("microsoft.com");
$ ps ax |grep ping
27012 ? S 0:00 sh -c cd '/prj/htdocs/net' ; /bin/ping -q
-w 10 -c 10 -s 32 microsoft.com
27013 ? S 0:00 /bin/ping -q -w 10 -c 10 -s 32
microsoft.com
And the code:
$ping = Net_Ping::factory();
if(!PEAR::isError($ping))
{
$ping->setArgs(array(
'count' => 4,
'ttl' => 60,
));
//$response = $ping->ping('microsoft.com');
$response = $ping->checkHost('microsoft.com');
}
else
{
$errors[] = $ping->getMessage();
}
------------------------------------------------------------------------
[2009-02-25 14:44:56] cconstantine
Request for additional info:
...can you redo your 'ps' info with the 'j' flag. I'm curious about the
Ping
process' "STAT" flags.
...does the checkHost() method work [not hang]? The checkHost() method
attempts to set ping's "deadline" argument based on its idea of how
your
system's ping works.
------------------------------------------------------------------------
[2009-02-25 13:54:02] babineau
Description:
------------
Using Net_Ping 2.4.4 (stable).
When pinging a remote host with ICMP filtered at the firewall,
exec() seems to never return. Running ping from the command line comes
back after a bit, but when run through the script it never stops.
Here's a ps after waiting >5 minutes for the script to return:
$ ps -ef|grep ping
apache 26061 23830 0 09:01 ? 00:00:00 sh -c cd
'/prj/htdocs/net' ; /bin/ping -c 4 -t 60 microsoft.com
apache 26062 26061 0 09:01 ? 00:00:00 /bin/ping -c 4 -t 60
microsoft.com
Now same command from the commandline:
$ /bin/ping -c 4 -t 60 microsoft.com
PING microsoft.com (207.46.232.182) 56(84) bytes of data.
ps -ef |grep
--- microsoft.com ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 2999ms
$
Test script:
---------------
$ping = Net_Ping::factory();
if(!PEAR::isError($ping))
{
$ping->setArgs(array(
'count' => 4,
'ttl' => 60,
));
$response = $ping->ping('microsoft.com');
}
else
{
$errors[] = $ping->getMessage();
}
Expected result:
----------------
$response include the parsed ping result.
Actual result:
--------------
Nothing is the actual result. It just hangs.
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=15941&edit=1