diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 91614235d2..034415e02a 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -337,6 +337,26 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $this->assertEquals($termSignal, $process->getTermSignal()); } + public function testProcessThrowsExceptionWhenExternallySignaled() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('Windows does not support POSIX signals'); + } + + if (!function_exists('posix_kill')) { + $this->markTestSkipped('posix_kill is required for this test'); + } + + $termSignal = defined('SIGKILL') ? SIGKILL : 9; + + $process = $this->getProcess('exec php -r "while (true) {}"'); + $process->start(); + posix_kill($process->getPid(), $termSignal); + + $this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'The process stopped because of a "9" signal.'); + $process->wait(); + } + public function testRestart() { $process1 = $this->getProcess('php -r "echo getmypid();"'); diff --git a/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php b/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php index 37c348d35d..2e364d6392 100644 --- a/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php @@ -133,6 +133,11 @@ class SigchildDisabledProcessTest extends AbstractProcessTest $this->markTestSkipped('Stopping with signal is not supported in sigchild environment'); } + public function testProcessThrowsExceptionWhenExternallySignaled() + { + $this->markTestSkipped('Retrieving Pid is not supported in sigchild environment'); + } + /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php b/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php index deec3a6504..40ffb772b7 100644 --- a/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php @@ -84,7 +84,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest { parent::testSignal(); } - + /** * @expectedException Symfony\Component\Process\Exception\RuntimeException */ @@ -93,6 +93,11 @@ class SigchildEnabledProcessTest extends AbstractProcessTest parent::testProcessWithoutTermSignalIsNotSignaled(); } + public function testProcessThrowsExceptionWhenExternallySignaled() + { + $this->markTestSkipped('Retrieving Pid is not supported in sigchild environment'); + } + /** * {@inheritdoc} */