add shutdown handler as anonymous function

This commit is contained in:
Art4 2024-12-28 22:50:49 +00:00
parent 24ce6180c4
commit 6e44d6c7e4

View file

@ -148,7 +148,10 @@ if (!$foreground) {
}
// We now are in the child process
register_shutdown_function('shutdown');
register_shutdown_function(function (): void {
posix_kill(posix_getpid(), SIGTERM);
posix_kill(posix_getpid(), SIGHUP);
});
// Make the child the main process, detach it from the terminal
if (posix_setsid() < 0) {
@ -168,9 +171,3 @@ set_time_limit(0);
// Now running as a daemon.
$jetstream = $dice->create(Jetstream::class);
$jetstream->listen();
function shutdown()
{
posix_kill(posix_getpid(), SIGTERM);
posix_kill(posix_getpid(), SIGHUP);
}