Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ad63d0b

Browse filesBrowse files
PaolaRubynicolas-grekas
authored andcommitted
[Console] Run commands when implements SignalableCommandInterface without pcntl and they have'nt signals
1 parent 1f6a5a7 commit ad63d0b
Copy full SHA for ad63d0b

File tree

2 files changed

+15
-2
lines changed
Filter options

2 files changed

+15
-2
lines changed

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
940940
}
941941
}
942942

943-
if ($command instanceof SignalableCommandInterface) {
943+
if ($command instanceof SignalableCommandInterface && ($this->signalsToDispatchEvent || $command->getSubscribedSignals())) {
944944
if (!$this->signalRegistry) {
945945
throw new RuntimeException('Unable to subscribe to signal events. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.');
946946
}

‎src/Symfony/Component/Console/Tests/ApplicationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/ApplicationTest.php
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use Symfony\Component\Console\Output\Output;
3737
use Symfony\Component\Console\Output\OutputInterface;
3838
use Symfony\Component\Console\Output\StreamOutput;
39+
use Symfony\Component\Console\SignalRegistry\SignalRegistry;
3940
use Symfony\Component\Console\Tester\ApplicationTester;
4041
use Symfony\Component\DependencyInjection\ContainerBuilder;
4142
use Symfony\Component\EventDispatcher\EventDispatcher;
@@ -1861,6 +1862,18 @@ public function testSignal()
18611862
$this->assertTrue($command->signaled);
18621863
$this->assertTrue($dispatcherCalled);
18631864
}
1865+
1866+
public function testSignalableCommandInterfaceWithoutSignals()
1867+
{
1868+
$command = new SignableCommand();
1869+
1870+
$dispatcher = new EventDispatcher();
1871+
$application = new Application();
1872+
$application->setAutoExit(false);
1873+
$application->setDispatcher($dispatcher);
1874+
$application->add($command);
1875+
$this->assertSame(0, $application->run(new ArrayInput(['signal'])));
1876+
}
18641877
}
18651878

18661879
class CustomApplication extends Application
@@ -1928,7 +1941,7 @@ class SignableCommand extends Command implements SignalableCommandInterface
19281941

19291942
public function getSubscribedSignals(): array
19301943
{
1931-
return [\SIGALRM];
1944+
return SignalRegistry::isSupported() ? [\SIGALRM] : [];
19321945
}
19331946

19341947
public function handleSignal(int $signal): void

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.