Re: killing a process through php webservice

From: Date: Fri, 08 Feb 2008 05:03:30 +0000
Subject: Re: killing a process through php webservice
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-268926@lists.php.net to get a copy of this message
Fahad javed wrote:
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.
Try a full path: /bin/kill or whatever it is. in php, try: <?php $kill_path = '/bin/kill'; echo 'can find kill: ' . is_file($kill_path) . '<br/>'; that will tell you whether php can see the file or not. Other stuff like safe-mode being enabled, open_basedir restrictions and this fn can be disabled (echo ini_get('disabled_functions')) all affect whether this will work or not. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#268926) next »