1
0
Fork 0

Add debug output when SIGINT is received

pull/9494/head
Jordi Boggiano 2020-11-16 22:42:21 +01:00
parent 8ed2aa8d6d
commit 4ac6f57d18
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 8 additions and 2 deletions

View File

@ -183,6 +183,7 @@ class InstallationManager
$cleanupPromises = array(); $cleanupPromises = array();
$loop = $this->loop; $loop = $this->loop;
$io = $this->io;
$runCleanup = function () use (&$cleanupPromises, $loop) { $runCleanup = function () use (&$cleanupPromises, $loop) {
$promises = array(); $promises = array();
@ -213,7 +214,8 @@ class InstallationManager
if ($handleInterruptsUnix) { if ($handleInterruptsUnix) {
pcntl_async_signals(true); pcntl_async_signals(true);
$prevHandler = pcntl_signal_get_handler(SIGINT); $prevHandler = pcntl_signal_get_handler(SIGINT);
pcntl_signal(SIGINT, function ($sig) use ($runCleanup, $prevHandler) { pcntl_signal(SIGINT, function ($sig) use ($runCleanup, $prevHandler, $io) {
$io->writeError('Received SIGINT, aborting', true, IOInterface::DEBUG);
$runCleanup(); $runCleanup();
if (!in_array($prevHandler, array(SIG_DFL, SIG_IGN), true)) { if (!in_array($prevHandler, array(SIG_DFL, SIG_IGN), true)) {
@ -224,7 +226,11 @@ class InstallationManager
}); });
} }
if ($handleInterruptsWindows) { if ($handleInterruptsWindows) {
$windowsHandler = function () use ($runCleanup) { $windowsHandler = function ($event) use ($runCleanup, $io) {
if ($event !== PHP_WINDOWS_EVENT_CTRL_C) {
return;
}
$io->writeError('Received CTRL+C, aborting', true, IOInterface::DEBUG);
$runCleanup(); $runCleanup();
exit(130); exit(130);