note 68149 deleted from function.phpversion by derick
| From: | derick@php.net | Date: | Fri, 04 Aug 2006 13:20:26 +0000 |
| Subject: | note 68149 deleted from function.phpversion by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-115548@lists.php.net to get a copy of this message | ||
Note Submitter: Sayid say at id dot or dot id, godril at lesehan dot or dot id
----
When PHP is running under fastcgi, script from ground-pilot at net-pilots.com didn't work as
expected. Otherwise, the php (fcgi one) is waiting for input and causing idle php-cgi processes
showed in 'ps aux'. I think this is because in fastcgi mode, direct execution to php fcgi
binary is waiting for input. So, giving it /dev/null as input is a workaround for this situation.
First, we build a script from PHP which we will executed and then unlink() it after a success. The
output script might look like:
<?
$script=<<<HEREDOC
#!/bin/sh
/usr/local/bin/php-cgi -v < /dev/null \n
HEREDOC;
$file = "/tmp/phpgetvercmd" . rand ( );
$fh = fopen ( $file , "w" );
fwrite ( $fh, $script );
fclose ( $fh );
chmod ( $file, 0755 );
echo trim( substr ( shell_exec ( $file ), 3, 6 ) );
unlink ( $file );
?>