util: fix pkill when no process

pull/260/head
Varun Patil 2023-01-04 12:46:13 -08:00
parent 33a14932c4
commit 5ce8e1d438
1 changed files with 4 additions and 1 deletions

View File

@ -149,7 +149,10 @@ class Util
public static function pkill(string $name): void
{
// get pids using ps as array
$pids = shell_exec("ps -ef | grep $name | grep -v grep | awk '{print $2}'");
$pids = shell_exec("ps -ef | grep {$name} | grep -v grep | awk '{print $2}'");
if (null === $pids || empty($pids)) {
return;
}
$pids = array_filter(explode("\n", $pids));
// kill all pids