Skip to content

Commit f9961fe

Browse files
committed
Use SIGTERM as default signal if SIGKILL is undefined
1 parent b14abb6 commit f9961fe

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/ProcessLauncher.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ public function createDeferredShell($process)
4141
// forcefully terminate process when stream closes
4242
$stream->on('close', function () use ($process) {
4343
if ($process->isRunning()) {
44-
$process->terminate(SIGKILL);
44+
if (defined('SIGKILL')) {
45+
$process->terminate(SIGKILL);
46+
} else {
47+
$process->terminate(null);
48+
}
4549
}
4650
});
4751

tests/ProcessLauncherTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ public function testClosingStreamTerminatesRunningProcess()
3838
$process->stdin->expects($this->any())->method('isWritable')->willReturn(true);
3939

4040
$process->expects($this->once())->method('isRunning')->will($this->returnValue(true));
41-
$process->expects($this->once())->method('terminate')->with($this->equalTo(SIGKILL));
41+
if (defined('SIGKILL')) {
42+
$process->expects($this->once())->method('terminate')->with($this->equalTo(SIGKILL));
43+
} else {
44+
$process->expects($this->once())->method('terminate')->with($this->equalTo(null));
45+
}
4246

4347
$shell = $this->processLauncher->createDeferredShell($process);
4448

0 commit comments

Comments
 (0)