|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-12-18 03:12 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 14:00:01 2025 UTC |
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.