]> git.mxchange.org Git - friendica.git/commitdiff
Check if the daemon pid file can be written
authorMichael <heluecht@pirati.ca>
Tue, 5 Dec 2023 21:18:44 +0000 (21:18 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 5 Dec 2023 21:18:44 +0000 (21:18 +0000)
bin/daemon.php

index cd774fe25ebdc54c287de9de8945d96c4a7dfc41..1a604d71357da63c2969b597d6b43ca533143950 100755 (executable)
@@ -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);
        }