From 2970a976d52abd83e85c6d238055bc8982d4e1e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 22 Jul 2018 18:28:39 +0200 Subject: [PATCH] Fixes: (#5447) - rewrote to first check if PID file is readable, then if found load it - next addition is to cast it's content to int. Any non-integer content will result in 0 (as I know). - Give warnings a voice! (xdebug's scream option showed a warning) - added some spaces for better readability --- bin/daemon.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/daemon.php b/bin/daemon.php index 475bafc09d..449f92d127 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -17,9 +17,9 @@ if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) { $directory = dirname($_SERVER["argv"][0]); if (substr($directory, 0, 1) != "/") { - $directory = $_SERVER["PWD"]."/".$directory; + $directory = $_SERVER["PWD"] . "/" . $directory; } - $directory = realpath($directory."/.."); + $directory = realpath($directory . "/.."); chdir($directory); } @@ -65,7 +65,11 @@ if (empty($_SERVER["argv"][0])) { die("Unexpected script behaviour. This message should never occur.\n"); } -$pid = @file_get_contents($pidfile); +$pid = null; + +if (is_readable($pidfile)) { + $pid = intval(file_get_contents($pidfile)); +} if (empty($pid) && in_array($mode, ["stop", "status"])) { Config::set('system', 'worker_daemon_mode', false); -- 2.39.5