killing process through exec()
Posted: Wed Feb 06, 2008 10:25 pm
I am developing a webservice in PHP/Linux where I need to kill a process.
I tried using
exec("kill ".$pid);
and
exec("kill -KILL ".$pid);
but the return value was always 1 and the process still remained.
I wrote up a small shell script and have exec run that script. The script worked fine if invoked through command line but through php it didn't do anything.
I have a hunch that this is because killing a process might need root privilages so I updated the script to:
sudo -p my_passsword -u root kill $pid
yet it didn't work.
I still think the problem is access rights. question is how to solve it.
Any help will be greatly appreciated.
Sincerely
Fahad
I tried using
exec("kill ".$pid);
and
exec("kill -KILL ".$pid);
but the return value was always 1 and the process still remained.
I wrote up a small shell script and have exec run that script. The script worked fine if invoked through command line but through php it didn't do anything.
I have a hunch that this is because killing a process might need root privilages so I updated the script to:
sudo -p my_passsword -u root kill $pid
yet it didn't work.
I still think the problem is access rights. question is how to solve it.
Any help will be greatly appreciated.
Sincerely
Fahad