I am facing one issue regarding killing a Linux process from my php code. I am running a Scrapy tool from my php code using the proc_open() function in the back
proc_open()
Never, ever, give apache sudo permissions!
sudo
Use exec("kill -9 $pid"); - your apache process started it, it can kill it :)
exec("kill -9 $pid");