Ensure signalHandler is kept around and unregistered
parent
4aa3258d19
commit
f0ab518c46
|
@ -81,6 +81,9 @@ class Application extends BaseApplication
|
|||
*/
|
||||
private $initialWorkingDirectory;
|
||||
|
||||
/** @var SignalHandler */
|
||||
private $signalHandler;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
static $shutdownRegistered = false;
|
||||
|
@ -96,13 +99,13 @@ class Application extends BaseApplication
|
|||
|
||||
$this->io = new NullIO();
|
||||
|
||||
$this->signalHandler = SignalHandler::create([SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP], function (string $signal, SignalHandler $handler) {
|
||||
$this->io->writeError('Received '.$signal.', aborting', true, IOInterface::DEBUG);
|
||||
|
||||
$handler->exitWithLastSignal();
|
||||
});
|
||||
|
||||
if (!$shutdownRegistered) {
|
||||
$signalHandler = SignalHandler::create([SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP], function (string $signal, SignalHandler $handler) {
|
||||
$this->io->writeError('Received '.$signal.', aborting', true, IOInterface::DEBUG);
|
||||
|
||||
$handler->exitWithLastSignal();
|
||||
});
|
||||
|
||||
$shutdownRegistered = true;
|
||||
|
||||
register_shutdown_function(static function (): void {
|
||||
|
@ -121,6 +124,11 @@ class Application extends BaseApplication
|
|||
parent::__construct('Composer', Composer::getVersion());
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->signalHandler->unregister();
|
||||
}
|
||||
|
||||
public function run(InputInterface $input = null, OutputInterface $output = null): int
|
||||
{
|
||||
if (null === $output) {
|
||||
|
|
Loading…
Reference in New Issue