Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ccb67d7

Browse files
[Process] Always call proc_close
1 parent 800232c commit ccb67d7

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin
157157

158158
public function __destruct()
159159
{
160-
if ($this->isRunning()) {
161-
$this->doSignal(15, false);
162-
usleep(10000);
163-
}
164-
if ($this->isRunning()) {
165-
usleep(100000);
166-
$this->doSignal(9, false);
167-
}
168-
169-
// Don't call ->stop() nor ->close() since we don't want to wait for the subprocess here
160+
$this->stop(0);
170161
}
171162

172163
public function __clone()

src/Symfony/Component/Process/Tests/AbstractProcessTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -709,26 +709,23 @@ public function testCheckTimeoutOnTerminatedProcess()
709709
*/
710710
public function testCheckTimeoutOnStartedProcess()
711711
{
712-
$timeout = 0.5;
713-
$precision = 100000;
714712
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
715-
$process->setTimeout($timeout);
716-
$start = microtime(true);
713+
$process->setTimeout(0.5);
717714

718715
$process->start();
716+
$start = microtime(true);
719717

720718
try {
721719
while ($process->isRunning()) {
722720
$process->checkTimeout();
723-
usleep($precision);
721+
usleep(100000);
724722
}
725723
$this->fail('A RuntimeException should have been raised');
726724
} catch (RuntimeException $e) {
727725
}
728726
$duration = microtime(true) - $start;
729727

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

733730
throw $e;
734731
}

src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,9 @@ public function testProcessWithoutTermSignal()
8585
parent::testProcessWithoutTermSignal();
8686
}
8787

88-
/**
89-
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
90-
* @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.
91-
*/
9288
public function testCheckTimeoutOnStartedProcess()
9389
{
94-
parent::testCheckTimeoutOnStartedProcess();
90+
$this->markTestSkipped('Stopping with signal is not supported in sigchild environment');
9591
}
9692

9793
/**

0 commit comments

Comments
 (0)