[Process] Fix for #8754 (Timed-out processes are successful)

This commit is contained in:
Romain Neutron 2013-08-14 17:41:18 +02:00 committed by Fabien Potencier
parent 4af7276f89
commit fa01e6b4d3
3 changed files with 11 additions and 2 deletions

View File

@ -646,9 +646,9 @@ class Process
$timeoutMicro = microtime(true) + $timeout; $timeoutMicro = microtime(true) + $timeout;
if ($this->isRunning()) { if ($this->isRunning()) {
proc_terminate($this->process); proc_terminate($this->process);
while ($this->isRunning() && microtime(true) < $timeoutMicro) { do {
usleep(1000); usleep(1000);
} } while ($this->isRunning() && microtime(true) < $timeoutMicro);
if ($this->isRunning() && !$this->isSigchildEnabled()) { if ($this->isRunning() && !$this->isSigchildEnabled()) {
if (null !== $signal || defined('SIGKILL')) { if (null !== $signal || defined('SIGKILL')) {

View File

@ -444,6 +444,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
$duration = microtime(true) - $start; $duration = microtime(true) - $start;
$this->assertLessThan($timeout + $precision, $duration); $this->assertLessThan($timeout + $precision, $duration);
$this->assertFalse($process->isSuccessful());
} }
public function testGetPid() public function testGetPid()

View File

@ -61,6 +61,14 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
parent::testProcessWithoutTermSignal(); parent::testProcessWithoutTermSignal();
} }
/**
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testCheckTimeoutOnStartedProcess()
{
parent::testCheckTimeoutOnStartedProcess();
}
/** /**
* @expectedException \Symfony\Component\Process\Exception\RuntimeException * @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/ */