Merge pull request #13697 from annando/check-daemon

Check if the daemon pid file can be written
This commit is contained in:
Hypolite Petovan 2023-12-05 16:57:42 -05:00 committed by GitHub
commit 085fb95ce3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -163,9 +163,14 @@ if (!$foreground) {
exit(1);
} elseif ($pid) {
// The parent process continues here
if (!file_put_contents($pidfile, $pid)) {
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);
}