diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 2bfb2441e1..35d48ed081 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -23,6 +23,7 @@ use Symfony\Component\Process\ProcessPipes; class ProcessTest extends \PHPUnit_Framework_TestCase { private static $phpBin; + private static $process; private static $sigchild; private static $notEnhancedSigchild = false; @@ -42,6 +43,14 @@ class ProcessTest extends \PHPUnit_Framework_TestCase self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild'); } + protected function tearDown() + { + if (self::$process) { + self::$process->stop(0); + self::$process = null; + } + } + public function testThatProcessDoesNotThrowWarningDuringRun() { @trigger_error('Test Error', E_USER_NOTICE); @@ -122,9 +131,9 @@ class ProcessTest extends \PHPUnit_Framework_TestCase $h = new \ReflectionProperty($p, 'process'); $h->setAccessible(true); $h = $h->getValue($p); - $s = proc_get_status($h); + $s = @proc_get_status($h); - while ($s['running']) { + while (!empty($s['running'])) { usleep(1000); $s = proc_get_status($h); } @@ -1012,7 +1021,11 @@ class ProcessTest extends \PHPUnit_Framework_TestCase } } - return $process; + if (self::$process) { + self::$process->stop(0); + } + + return self::$process = $process; } private function skipIfNotEnhancedSigchild($expectException = true)