mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Process: add subprocess parameter to kill()
fix CommandReader subprocess lingering on a crash and fucking up the console
This commit is contained in:
parent
2566123e49
commit
dd0c2fed82
@ -300,7 +300,7 @@ JIT_WARNING
|
||||
|
||||
if(ThreadManager::getInstance()->stopAll() > 0){
|
||||
$logger->debug("Some threads could not be stopped, performing a force-kill");
|
||||
Process::kill(Process::pid());
|
||||
Process::kill(Process::pid(), true);
|
||||
}
|
||||
}while(false);
|
||||
|
||||
|
@ -1371,7 +1371,7 @@ class Server{
|
||||
}catch(\Throwable $e){
|
||||
$this->logger->logException($e);
|
||||
$this->logger->emergency("Crashed while crashing, killing process");
|
||||
@Process::kill(Process::pid());
|
||||
@Process::kill(Process::pid(), true);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1501,7 +1501,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());
|
||||
@Process::kill(Process::pid(), true);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -125,18 +125,21 @@ final class Process{
|
||||
return count(ThreadManager::getInstance()->getAll()) + 2; //MainLogger + Main Thread
|
||||
}
|
||||
|
||||
public static function kill(int $pid) : void{
|
||||
public static function kill(int $pid, bool $subprocesses) : void{
|
||||
$logger = \GlobalLogger::get();
|
||||
if($logger instanceof MainLogger){
|
||||
$logger->syncFlushBuffer();
|
||||
}
|
||||
switch(Utils::getOS()){
|
||||
case Utils::OS_WINDOWS:
|
||||
exec("taskkill.exe /F /PID $pid > NUL");
|
||||
exec("taskkill.exe /F " . ($subprocesses ? "/T " : "") . "/PID $pid");
|
||||
break;
|
||||
case Utils::OS_MACOS:
|
||||
case Utils::OS_LINUX:
|
||||
default:
|
||||
if($subprocesses){
|
||||
$pid = -$pid;
|
||||
}
|
||||
if(function_exists("posix_kill")){
|
||||
posix_kill($pid, 9); //SIGKILL
|
||||
}else{
|
||||
|
@ -50,7 +50,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());
|
||||
@Process::kill(Process::pid(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user