Fix Windows missing SIGINT bug

This commit is contained in:
crazywhalecc
2025-04-29 14:52:24 +08:00
parent 92483cf188
commit 348decf72f

View File

@@ -148,10 +148,13 @@ class CraftCommand extends BaseCommand
if (PHP_OS_FAMILY === 'Windows') { if (PHP_OS_FAMILY === 'Windows') {
sapi_windows_set_ctrl_handler(function () use ($process) { sapi_windows_set_ctrl_handler(function () use ($process) {
$process->signal(SIGINT); if ($process->isRunning()) {
$process->signal(-1073741510);
}
}); });
} elseif (extension_loaded('pcntl')) { } elseif (extension_loaded('pcntl')) {
pcntl_signal(SIGINT, function () use ($process) { pcntl_signal(SIGINT, function () use ($process) {
/* @noinspection PhpComposerExtensionStubsInspection */
$process->signal(SIGINT); $process->signal(SIGINT);
}); });
} else { } else {