Closed
Description
I'm writing a set of scripts to manage out hosting setup based on Cilex and i'm trying to kill all the processes of a user before i remove the user (in a remove project script)
I've got the following method (just a copy paste from the manual)
public function executeCommand($command, OutputInterface $output, $silent = false)
{
$output->writeln("<comment> $ " . $command . "</comment>");
$process = new Process($command);
$process->run();
if (!$process->isSuccessful()) {
if (!$silent) {
$output->writeln("<error> " . $process->getErrorOutput() . "</error>");
}
return false;
}
return $process->getOutput();
}
and I send in the following command:
$process->executeCommand("su - ".$username." -c 'kill -9 -1'",$output, true);
The command throws a RuntimeException complaining that the command ended with a 0 signal. Wile as far as I understand is 0 a successful statuscode.
[15:07:42][root@kserver /opt/kServer](master *%)$ ./kserver remove test
Are you sure you want to remove test?y
---> Removing project test
---> Running backup on project test
> Loading the project config from /var/www/test/config/project.yml
> Running preBackup of the base skeleton
$ mkdir -p /var/backup
$ nice -n 19 tar --create --absolute-names --file /var/backup/test.tar.gz --totals --gzip /var/www/test/ 2>&1
> Running postBackup of the base skeleton
$ su - test -c 'kill -9 -1'
[RuntimeException]
The process stopped because of a "0" signal.
remove [name]
I'm running this command on an Ubuntu 12.04 in Vagrant/Virtualbox using PHP 5.4.6 as "root"