minor #16875 [Process] Always call proc_close (nicolas-grekas)

This PR was merged into the 2.3 branch.

Discussion
----------

[Process] Always call proc_close

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #15617
| License       | MIT
| Doc PR        | -

This should fix one more transient test, and a wrong behavior.

Commits
-------

ccb67d7 [Process] Always call proc_close
This commit is contained in:
Nicolas Grekas 2015-12-08 18:10:57 +01:00
commit ed226961ab
3 changed files with 6 additions and 22 deletions

View File

@ -157,16 +157,7 @@ class Process
public function __destruct() public function __destruct()
{ {
if ($this->isRunning()) { $this->stop(0);
$this->doSignal(15, false);
usleep(10000);
}
if ($this->isRunning()) {
usleep(100000);
$this->doSignal(9, false);
}
// Don't call ->stop() nor ->close() since we don't want to wait for the subprocess here
} }
public function __clone() public function __clone()

View File

@ -709,26 +709,23 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
*/ */
public function testCheckTimeoutOnStartedProcess() public function testCheckTimeoutOnStartedProcess()
{ {
$timeout = 0.5;
$precision = 100000;
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"'); $process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
$process->setTimeout($timeout); $process->setTimeout(0.5);
$start = microtime(true);
$process->start(); $process->start();
$start = microtime(true);
try { try {
while ($process->isRunning()) { while ($process->isRunning()) {
$process->checkTimeout(); $process->checkTimeout();
usleep($precision); usleep(100000);
} }
$this->fail('A RuntimeException should have been raised'); $this->fail('A RuntimeException should have been raised');
} catch (RuntimeException $e) { } catch (RuntimeException $e) {
} }
$duration = microtime(true) - $start; $duration = microtime(true) - $start;
$this->assertLessThan($timeout + $precision, $duration); $this->assertLessThan(1, $duration);
$this->assertFalse($process->isSuccessful());
throw $e; throw $e;
} }

View File

@ -85,13 +85,9 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
parent::testProcessWithoutTermSignal(); parent::testProcessWithoutTermSignal();
} }
/**
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.
*/
public function testCheckTimeoutOnStartedProcess() public function testCheckTimeoutOnStartedProcess()
{ {
parent::testCheckTimeoutOnStartedProcess(); $this->markTestSkipped('Stopping with signal is not supported in sigchild environment');
} }
/** /**