Ashley Sheridan pisze:
> On Wed, 2009-05-27 at 10:25 +0200, Kamil Walas wrote:
>> Hi,
>> I stuck with strange error. I have following code:
>> <?
>>      echo 'BEFORE';
>>      echo exec("ping -c1 -w1");
>>      echo 'AFTER';
>> ?>
>> Address doesn't exist. When execute script from command line everything
>> works fine. But when I go to the file by Firefox it hangs out and apache
>> need to be restart. This is a Virtual Server with PHP Version
>> 5.2.6-pl222-gentoo. When address exists it works fine. Only problem is
>> when it doesn't respond and apache hangs.
>> I copy file to apache at my local apache and everything works fine. My
>> apache is with Version 5.3.0alpha3-dev at windows XP.
>> At old server with php4 everything works fine.
>> I suspect that something wrong is with apache configuration but I don't
>> know it for sure and couldn't find it.
>> Thank you,
>> Kamil Walas
> Are you sure it's crashed and is not just waiting for a reply from the
> remote server. How long do you leave it running before you assume it's
> crashed? I see it's set for a 1millisecond wait response, but what is
> the -c1 flag, as I'm not familiar with all the flags of a Windows ping,
> and a quick Google didn't reveal it.
> Ash

It is waiting. Not crash but hangs. Id don't know why. For test once I leave it for something about 2 hours - for one ping it should be enought. -c1 flag tells to send only one ping. It hangs on Gentoo.

I solved it by removing exec.
Now it looks like:
function ping( $host, $number_port, $timeout )
$fp = fsockopen($host, $number_port, $a, $timeout); if($fp !== FALSE ) { fclose($fp); return true;} else { return false; } }
It's better than ping becouse there is also a port number check.

Thanks for fast answer,

Kamil Walas

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to