diff --git a/src/SPC/command/DoctorCommand.php b/src/SPC/command/DoctorCommand.php index 9aabdeca..bc77511a 100644 --- a/src/SPC/command/DoctorCommand.php +++ b/src/SPC/command/DoctorCommand.php @@ -75,8 +75,9 @@ class DoctorCommand extends BaseCommand } catch (\Throwable $e) { $this->output->writeln('' . $e->getMessage() . ''); - pcntl_signal(SIGINT, SIG_IGN); - + if (extension_loaded('pcntl')) { + pcntl_signal(SIGINT, SIG_IGN); + } return static::FAILURE; } diff --git a/src/SPC/doctor/CheckListHandler.php b/src/SPC/doctor/CheckListHandler.php index bfeb39c4..de5733df 100644 --- a/src/SPC/doctor/CheckListHandler.php +++ b/src/SPC/doctor/CheckListHandler.php @@ -34,12 +34,23 @@ final class CheckListHandler */ public function emitFix(OutputInterface $output, CheckResult $result): void { - pcntl_signal(SIGINT, function () use ($output) { - $output->writeln('You cancelled fix'); - }); + if (PHP_OS_FAMILY === 'Windows') { + sapi_windows_set_ctrl_handler(function () use ($output) { + $output->writeln('You cancelled fix'); + }); + } elseif (extension_loaded('pcntl')) { + pcntl_signal(SIGINT, function () use ($output) { + $output->writeln('You cancelled fix'); + }); + } $fix_result = call_user_func($this->fix_map[$result->getFixItem()], ...$result->getFixParams()); - pcntl_signal(SIGINT, SIG_IGN); + + if (PHP_OS_FAMILY === 'Windows') { + sapi_windows_set_ctrl_handler(null); + } elseif (extension_loaded('pcntl')) { + pcntl_signal(SIGINT, SIG_IGN); + } if ($fix_result) { $output->writeln('Fix done'); diff --git a/src/SPC/doctor/item/OSCheckList.php b/src/SPC/doctor/item/OSCheckList.php index ad6b2551..60ce10c6 100644 --- a/src/SPC/doctor/item/OSCheckList.php +++ b/src/SPC/doctor/item/OSCheckList.php @@ -17,7 +17,7 @@ class OSCheckList public function checkOS(): ?CheckResult { if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) { - return CheckResult::fail('Current OS is not supported'); + return CheckResult::fail('Current OS is not supported: ' . PHP_OS_FAMILY); } $distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : ''; return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported');