1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00
This commit is contained in:
J. King 2021-06-20 17:17:57 -04:00
parent 23749b51aa
commit b9fd9ac32e

View file

@ -76,8 +76,8 @@ class Daemon {
protected function checkPID(string $pidfile) { protected function checkPID(string $pidfile) {
if (file_exists($pidfile)) { if (file_exists($pidfile)) {
$pid = @file_get_contents($pidfile); $pid = (string) @file_get_contents($pidfile);
if (preg_match("/^\d+$/s", (string) $pid)) { if (preg_match("/^\d+$/s", $pid)) {
if ($this->processExists((int) $pid)) { if ($this->processExists((int) $pid)) {
throw new \Exception("Process already exists"); 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 { protected function processExists(int $pid): bool {
return @posix_kill($pid, 0); return @posix_kill($pid, 0);
} }