diff --git a/CHANGELOG.md b/CHANGELOG.md index a0fd508..cd150d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased * ... +## 1.2.1 [2023-08-23] +* Adds support for SIGQUIT signal (needed to support php-fpm-alpine docker images which overrides STOPSIGNAL ([Official Dockerfile](https://github.com/docker-library/php/blob/master/8.2/alpine3.18/fpm/Dockerfile#L259))) + ## 1.2.0 [2023-04-03] * Drop support to PHP 7.3 * Drop support to EOL Symfony versions (3.x, 4.0 to 4.3, 5.0 to 5.3) diff --git a/bin/terminable-loop-command.sh b/bin/terminable-loop-command.sh index 7152c9a..69f3bcf 100755 --- a/bin/terminable-loop-command.sh +++ b/bin/terminable-loop-command.sh @@ -12,7 +12,8 @@ _term() { wait $CHILD } -trap _term TERM +trap _term TERM SIGTERM +trap _term QUIT SIGQUIT while true; do $@ & diff --git a/tests/E2E/TerminateCommandTest.php b/tests/E2E/TerminateCommandTest.php index 822bc9a..d24036f 100644 --- a/tests/E2E/TerminateCommandTest.php +++ b/tests/E2E/TerminateCommandTest.php @@ -58,7 +58,10 @@ public function commandLineProvider(): array ]; } - public function testSigTermDuringCommandBody(): void + /** + * @dataProvider provideSignals + */ + public function testSignalsDuringCommandBody(int $signal, int $exitCode): void { $process = new Process([ self::BASH_COMMAND, @@ -73,7 +76,7 @@ public function testSigTermDuringCommandBody(): void $process->start(); sleep(1); - $process->signal(SIGTERM); + $process->signal($signal); $process->wait(); @@ -81,10 +84,13 @@ public function testSigTermDuringCommandBody(): void $this->assertStringContainsString('Starting ' . self::STUB_COMMAND, $process->getOutput()); $this->assertStringNotContainsString('Signal received, skipping execution', $process->getOutput()); $this->assertStringContainsString('Slept 0 second(s)', $process->getOutput()); - $this->assertSame(143, $process->getExitCode()); + $this->assertSame($exitCode, $process->getExitCode()); } - public function testSigTermDuringSleep(): void + /** + * @dataProvider provideSignals + */ + public function testSigTermDuringSleep(int $signal, int $exitCode): void { $process = new Process([ self::BASH_COMMAND, @@ -99,15 +105,26 @@ public function testSigTermDuringSleep(): void $process->start(); sleep(1); - $process->signal(SIGTERM); + $process->signal($signal); $process->wait(); $this->assertCommandIsFound($process); $this->assertStringContainsString('Starting ' . self::STUB_COMMAND, $process->getOutput()); $this->assertStringNotContainsString('Signal received, skipping execution', $process->getOutput()); - $this->assertMatchesRegularExpression('/Slept (0|1) second\(s\)/', $process->getOutput()); - $this->assertSame(143, $process->getExitCode()); + $this->assertRegExp('/Slept (0|1) second\(s\)/', $process->getOutput()); + $this->assertSame($exitCode, $process->getExitCode()); + } + + /** + * @return array + */ + public function provideSignals(): array + { + return [ + [SIGTERM, 143], + [SIGQUIT, 131], + ]; } /**