Skip to content

Commit 0095f18

Browse files
gabr1c0mGabriele 'gabricom' ColomberaJean85
authored
Add support for sigquit (#9)
* add support for sigquit * Update CHANGELOG.md Co-authored-by: Alessandro Lai <alessandro.lai85@gmail.com> --------- Co-authored-by: Gabriele 'gabricom' Colombera <gabriele.colombera@facile.it> Co-authored-by: Alessandro Lai <alessandro.lai85@gmail.com>
1 parent f0de1d9 commit 0095f18

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
## Unreleased
88
* ...
99

10+
## 1.2.1 [2023-08-23]
11+
* 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)))
12+
1013
## 1.2.0 [2023-04-03]
1114
* Drop support to PHP 7.3
1215
* Drop support to EOL Symfony versions (3.x, 4.0 to 4.3, 5.0 to 5.3)

bin/terminable-loop-command.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ _term() {
1212
wait $CHILD
1313
}
1414

15-
trap _term TERM
15+
trap _term TERM SIGTERM
16+
trap _term QUIT SIGQUIT
1617

1718
while true; do
1819
$@ &

tests/E2E/TerminateCommandTest.php

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ public function commandLineProvider(): array
5858
];
5959
}
6060

61-
public function testSigTermDuringCommandBody(): void
61+
/**
62+
* @dataProvider provideSignals
63+
*/
64+
public function testSignalsDuringCommandBody(int $signal, int $exitCode): void
6265
{
6366
$process = new Process([
6467
self::BASH_COMMAND,
@@ -73,18 +76,21 @@ public function testSigTermDuringCommandBody(): void
7376
$process->start();
7477

7578
sleep(1);
76-
$process->signal(SIGTERM);
79+
$process->signal($signal);
7780

7881
$process->wait();
7982

8083
$this->assertCommandIsFound($process);
8184
$this->assertStringContainsString('Starting ' . self::STUB_COMMAND, $process->getOutput());
8285
$this->assertStringNotContainsString('Signal received, skipping execution', $process->getOutput());
8386
$this->assertStringContainsString('Slept 0 second(s)', $process->getOutput());
84-
$this->assertSame(143, $process->getExitCode());
87+
$this->assertSame($exitCode, $process->getExitCode());
8588
}
8689

87-
public function testSigTermDuringSleep(): void
90+
/**
91+
* @dataProvider provideSignals
92+
*/
93+
public function testSigTermDuringSleep(int $signal, int $exitCode): void
8894
{
8995
$process = new Process([
9096
self::BASH_COMMAND,
@@ -99,15 +105,26 @@ public function testSigTermDuringSleep(): void
99105
$process->start();
100106

101107
sleep(1);
102-
$process->signal(SIGTERM);
108+
$process->signal($signal);
103109

104110
$process->wait();
105111

106112
$this->assertCommandIsFound($process);
107113
$this->assertStringContainsString('Starting ' . self::STUB_COMMAND, $process->getOutput());
108114
$this->assertStringNotContainsString('Signal received, skipping execution', $process->getOutput());
109-
$this->assertMatchesRegularExpression('/Slept (0|1) second\(s\)/', $process->getOutput());
110-
$this->assertSame(143, $process->getExitCode());
115+
$this->assertRegExp('/Slept (0|1) second\(s\)/', $process->getOutput());
116+
$this->assertSame($exitCode, $process->getExitCode());
117+
}
118+
119+
/**
120+
* @return array<array{int,int}>
121+
*/
122+
public function provideSignals(): array
123+
{
124+
return [
125+
[SIGTERM, 143],
126+
[SIGQUIT, 131],
127+
];
111128
}
112129

113130
/**

0 commit comments

Comments
 (0)