From b9fd9ac32ec227b3f6df7728ddad7d6e51723db5 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sun, 20 Jun 2021 17:17:57 -0400 Subject: [PATCH] Tweaks --- lib/Service/Daemon.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Service/Daemon.php b/lib/Service/Daemon.php index 4dc9d36..3fd615f 100644 --- a/lib/Service/Daemon.php +++ b/lib/Service/Daemon.php @@ -76,8 +76,8 @@ class Daemon { protected function checkPID(string $pidfile) { if (file_exists($pidfile)) { - $pid = @file_get_contents($pidfile); - if (preg_match("/^\d+$/s", (string) $pid)) { + $pid = (string) @file_get_contents($pidfile); + if (preg_match("/^\d+$/s", $pid)) { if ($this->processExists((int) $pid)) { throw new \Exception("Process already exists"); } @@ -108,6 +108,10 @@ class Daemon { } } + /** Wrapper around posix_kill (with signal 0) to facilitation testing + * + * @codeCoverageIgnore + */ protected function processExists(int $pid): bool { return @posix_kill($pid, 0); }