The Apache Haus Forum

Advanced search  

News:

Welcome to Apache Haus Distribution Forum

Pages: [1]   Go Down

Author Topic: PHP getting Apache pids or PHP pids  (Read 4619 times)

mario

  • Administrator
  • Member Elite
  • *****
  • Offline Offline
  • Posts: 579
PHP getting Apache pids or PHP pids
« on: March 02, 2009, 02:17:40 PM »

Sometimes it is usefull to get the PIDs from Apache or PHP which runs over FCGID to kill all the processes if it hangs up. Sometime I had that with the non thead safe version (NTS) to use its performance.

Code: [Select]
<?php
$wmi 
= new COM('winmgmts://');
$processes $wmi->ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'httpd.exe'");
foreach(
$processes as $process){
    echo 
'cmd line: '$process->CommandLine ' --> pid: '$process->ProcessId .'<br />';
}
//reference http://msdn2.microsoft.com/en-us/library/aa394372.aspx
?>


or replace httpd.exe with php-cgi.exe and that kill it instead of print it out.

Notice: if you want to kill php-cgi processes you have to run that script with the php module in apache  ;) Otherwise the script maybe kills itself.
Logged
Pages: [1]   Go Up
 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13