From 9b43ddecbd77e5ff750ed305eb7d0433a3bca6cc Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 20 Jul 2023 17:10:39 +0100 Subject: [PATCH] Drop usages of Process:kill() with subprocesses parameter we don't need this any more with console reader improvements, and this was not working correctly anyway. closes #5234 --- src/PocketMine.php | 2 +- src/Server.php | 6 +++--- src/console/ConsoleReaderChildProcess.php | 2 +- src/utils/Process.php | 5 ++++- src/utils/ServerKiller.php | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/PocketMine.php b/src/PocketMine.php index c653d33ea..cbab95c85 100644 --- a/src/PocketMine.php +++ b/src/PocketMine.php @@ -343,7 +343,7 @@ JIT_WARNING if(ThreadManager::getInstance()->stopAll() > 0){ $logger->debug("Some threads could not be stopped, performing a force-kill"); - Process::kill(Process::pid(), true); + Process::kill(Process::pid()); } }while(false); diff --git a/src/Server.php b/src/Server.php index d4aba8282..d1f7ea4b9 100644 --- a/src/Server.php +++ b/src/Server.php @@ -1446,7 +1446,7 @@ class Server{ private function forceShutdownExit() : void{ $this->forceShutdown(); - Process::kill(Process::pid(), true); + Process::kill(Process::pid()); } public function forceShutdown() : void{ @@ -1514,7 +1514,7 @@ class Server{ }catch(\Throwable $e){ $this->logger->logException($e); $this->logger->emergency("Crashed while crashing, killing process"); - @Process::kill(Process::pid(), true); + @Process::kill(Process::pid()); } } @@ -1668,7 +1668,7 @@ class Server{ echo "--- Waiting $spacing seconds to throttle automatic restart (you can kill the process safely now) ---" . PHP_EOL; sleep($spacing); } - @Process::kill(Process::pid(), true); + @Process::kill(Process::pid()); exit(1); } diff --git a/src/console/ConsoleReaderChildProcess.php b/src/console/ConsoleReaderChildProcess.php index 2d4e3fc56..20a3e5bf1 100644 --- a/src/console/ConsoleReaderChildProcess.php +++ b/src/console/ConsoleReaderChildProcess.php @@ -90,4 +90,4 @@ while(!feof($socket)){ //For simplicity's sake, we don't bother with a graceful shutdown here. //The parent process would normally forcibly terminate the child process anyway, so we only reach this point if the //parent process was terminated forcibly and didn't clean up after itself. -Process::kill(Process::pid(), false); +Process::kill(Process::pid()); diff --git a/src/utils/Process.php b/src/utils/Process.php index 96169b34f..c4dd848d5 100644 --- a/src/utils/Process.php +++ b/src/utils/Process.php @@ -125,7 +125,10 @@ final class Process{ return count(ThreadManager::getInstance()->getAll()) + 2; //MainLogger + Main Thread } - public static function kill(int $pid, bool $subprocesses) : void{ + /** + * @param bool $subprocesses @deprecated + */ + public static function kill(int $pid, bool $subprocesses = false) : void{ $logger = \GlobalLogger::get(); if($logger instanceof MainLogger){ $logger->syncFlushBuffer(); diff --git a/src/utils/ServerKiller.php b/src/utils/ServerKiller.php index 1739643d0..b7f415528 100644 --- a/src/utils/ServerKiller.php +++ b/src/utils/ServerKiller.php @@ -49,7 +49,7 @@ class ServerKiller extends Thread{ }); if(time() - $start >= $this->time){ echo "\nTook too long to stop, server was killed forcefully!\n"; - @Process::kill(Process::pid(), true); + @Process::kill(Process::pid()); } }