I have a simple script, which tries to kill an already running process. I am using posix_kill for the same. The script runs fine, if I run it from command shell, but doesn't work when I run it from the browser.
<?php
$taskid = 33;
killProcess($taskid);
function killProcess($taskid) {
$ppid = getPID($taskid);
echo "process id -- $ppid
";
$pids = preg_split('/\s+/', `ps -o pid --no-heading --ppid $ppid`);
var_dump($pids);
foreach($pids as $pid) {
if(is_numeric($pid)) {
echo "Killing $pid
";
posix_kill($pid, 15);
}
}
}
?>
I always get the following output, which means that the script is executing fine, but the process does not get killed: process id -- 4632 array (size=3) 0 => string '' (length=0) 1 => string '4633' (length=4) 2 => string '' (length=0) Killing 4633
I checked out the apache "error.log" file, and found that for each run that I do from browser, and additional entry gets added as follows: [Sat Jun 23 12:24:55 2012] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico
Unfortunately this error does not give me much information about what's going wrong. I checked out the php.ini settings, and there doesn't seem to be anything wrong (as per whatever limited understanding I have). I do not see posix_kill in the "disabled_functions" list etc or any other setting that should prevent me from executing process.
Would sincerely appreciate some help !!
Thanks, Kapil