mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 09:26:06 +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:
@ -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{
|
||||
|
Reference in New Issue
Block a user