eee
This commit is contained in:
@@ -126,7 +126,7 @@ class State extends Component
|
||||
}
|
||||
|
||||
$pid = (int)trim((string)file_get_contents($pidFile));
|
||||
if ($pid <= 1 || !$this->isProcessAlive($pid)) {
|
||||
if ($pid <= 1 || !$this->isProcessAlive($pid) || !$this->isSameAppProcess($pid)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -168,6 +168,9 @@ class State extends Component
|
||||
if (!preg_match('/\\]\\..+\\[[0-9]+\\]/', $command)) {
|
||||
continue;
|
||||
}
|
||||
if (!$this->isSameAppProcess((int)$process['pid'])) {
|
||||
continue;
|
||||
}
|
||||
$pids[] = (int)$process['pid'];
|
||||
}
|
||||
|
||||
@@ -203,6 +206,22 @@ class State extends Component
|
||||
}
|
||||
|
||||
|
||||
private function isSameAppProcess(int $pid): bool
|
||||
{
|
||||
$cwd = @readlink('/proc/' . $pid . '/cwd');
|
||||
if ($cwd === false || $cwd === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->normalizePath($cwd) === $this->normalizePath(APP_PATH);
|
||||
}
|
||||
|
||||
private function normalizePath(string $path): string
|
||||
{
|
||||
$real = realpath($path) ?: $path;
|
||||
return rtrim(str_replace('\\', '/', $real), '/');
|
||||
}
|
||||
|
||||
private function isProcessAlive(int $pid): bool
|
||||
{
|
||||
return $pid > 1 && @Process::kill($pid, 0);
|
||||
|
||||
Reference in New Issue
Block a user