Fix the service runtime

- The trim is required
- To prevent an error by using: ?? ''
This commit is contained in:
FusionPBX
2025-10-29 11:38:33 -06:00
committed by GitHub
parent f8ec330631
commit 6b795ed511

View File

@@ -57,9 +57,9 @@
if (!function_exists('is_running')) {
function is_running(string $name) {
$name = escapeshellarg($name);
$pid = shell_exec("ps -aux | grep $name | grep -v grep | awk '{print \$2}' | head -n 1");
$pid = trim(shell_exec("ps -aux | grep $name | grep -v grep | awk '{print \$2}' | head -n 1") ?? '');
if ($pid && is_numeric($pid)) {
$etime = shell_exec("ps -p $pid -o etime= | tr -d '\n'");
$etime = trim(shell_exec("ps -p $pid -o etime= | tr -d '\n'") ?? '');
return ['running' => true, 'pid' => $pid, 'etime' => $etime];
}
return ['running' => false, 'pid' => null, 'etime' => null];