From 6e44d6c7e4cd27da97a1e16151866abe70690fea Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 28 Dec 2024 22:50:49 +0000 Subject: [PATCH] add shutdown handler as anonymous function --- bin/jetstream.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/bin/jetstream.php b/bin/jetstream.php index 2a3b5999fa..eae05b8580 100755 --- a/bin/jetstream.php +++ b/bin/jetstream.php @@ -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); -}