From 8827d4c142f91d2166c8e2ee21ec7df04187b170 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 5 Dec 2023 21:18:44 +0000 Subject: [PATCH 1/2] Check if the daemon pid file can be written --- bin/daemon.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/daemon.php b/bin/daemon.php index cd774fe25e..1a604d7135 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -163,9 +163,15 @@ if (!$foreground) { exit(1); } elseif ($pid) { // The parent process continues here + file_put_contents($pidfile, $pid); + if (!is_readable($pidfile)) { + echo "Pid file wasn't written.\n"; + Logger::warning('Could not store pid file'); + posix_kill($pid, SIGTERM); + exit(1); + } echo 'Child process started with pid ' . $pid . ".\n"; Logger::notice('Child process started', ['pid' => $pid]); - file_put_contents($pidfile, $pid); exit(0); } From f430e06f80614e801348cdef5f2d9670785941c4 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 5 Dec 2023 22:45:16 +0100 Subject: [PATCH 2/2] Update bin/daemon.php Co-authored-by: Hypolite Petovan --- bin/daemon.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/daemon.php b/bin/daemon.php index 1a604d7135..53a564b8bc 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -163,8 +163,7 @@ if (!$foreground) { exit(1); } elseif ($pid) { // The parent process continues here - file_put_contents($pidfile, $pid); - if (!is_readable($pidfile)) { + if (!file_put_contents($pidfile, $pid)) { echo "Pid file wasn't written.\n"; Logger::warning('Could not store pid file'); posix_kill($pid, SIGTERM);