Cannot kill self-firing intinite loop PHP Apache processes

camursm asked:

I’ve fired a PHP file by mistake that calls itself and creates an infinite loop.

Now I’m trying to purge these processes, and I’ve done the following:

  • tried to kill the processes with kill pid, but more and more processes are created indefinitely
  • restarted Apache, this kills the main process and all the children, but as soon as I start Apache, they are all back
  • reinstalling Apache

I’m clueless as to what I can do next.

Any suggestions?


UPDATE: This is the part of the code that causes the script to call itself over and over

function run_background_process($url, $params) {

  // do a normal cURL POST
  $cmd = 'curl -X POST ';
  // append the URL to the script
  $cmd .= $url;
  // add any variables that needs to be passed to the target script
  $cmd .= ' -d "' . $params . '"';
  // run it in the background so it does not affect page load
  $cmd .= " > /dev/null 2>&1 &"; 
  // execute
  exec($cmd, $output, $exit); 
  return $exit == 0;

}

So, the script calls itself using cuRL (run_background_process(site_url) is called earlier in the script)

My answer:


Rename the PHP file. It will then be unable to call itself.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.