Skip to content

Commit

Permalink
[Process] Always call proc_close
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Dec 8, 2015
1 parent 800232c commit ccb67d7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
11 changes: 1 addition & 10 deletions src/Symfony/Component/Process/Process.php
Expand Up @@ -157,16 +157,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin

public function __destruct()
{
if ($this->isRunning()) {
$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
$this->stop(0);
}

public function __clone()
Expand Down
11 changes: 4 additions & 7 deletions src/Symfony/Component/Process/Tests/AbstractProcessTest.php
Expand Up @@ -709,26 +709,23 @@ public function testCheckTimeoutOnTerminatedProcess()
*/
public function testCheckTimeoutOnStartedProcess()
{
$timeout = 0.5;
$precision = 100000;
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
$process->setTimeout($timeout);
$start = microtime(true);
$process->setTimeout(0.5);

$process->start();
$start = microtime(true);

try {
while ($process->isRunning()) {
$process->checkTimeout();
usleep($precision);
usleep(100000);
}
$this->fail('A RuntimeException should have been raised');
} catch (RuntimeException $e) {
}
$duration = microtime(true) - $start;

$this->assertLessThan($timeout + $precision, $duration);
$this->assertFalse($process->isSuccessful());
$this->assertLessThan(1, $duration);

throw $e;
}
Expand Down
Expand Up @@ -85,13 +85,9 @@ public function 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()
{
parent::testCheckTimeoutOnStartedProcess();
$this->markTestSkipped('Stopping with signal is not supported in sigchild environment');
}

/**
Expand Down

0 comments on commit ccb67d7

Please sign in to comment.