8000 merged branch Seldaek/process_fix (PR #3838) · symfony/symfony@127cff0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 127cff0

Browse files
committed
merged branch Seldaek/process_fix (PR #3838)
Commits ------- 6dca141 [Process] Skip signal assertion on windows 4cd0fb4 [Process] Skip test that is still getting stuck on windows e82a05d [Process] Close pipes before calling proc_close to avoid deadlocks as advised on the proc_close php.net documentation f4227b5 [Process] Removing useless code (this is already done in updateStatus) 2d586d2 [Process] Fix a mistake triggering stream_select errors Discussion ---------- Process fixes A few fixes, including making the tests pass on windows and fixing composer/composer#543. Given the sensitivity of this code I did a bunch of very granular commits explaining everything.
2 parents d694858 + 6dca141 commit 127cff0

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,15 @@ public function start($callback = null)
213213

214214
if (null === $this->stdin) {
215215
fclose($this->pipes[0]);
216+
unset($this->pipes[0]);
216217

217218
return;
218219
} else {
219220
$writePipes = array($this->pipes[0]);
221+
unset($this->pipes[0]);
220222
$stdinLen = strlen($this->stdin);
221223
$stdinOffset = 0;
222224
}
223-
unset($this->pipes[0]);
224225

225226
while ($writePipes) {
226227
$r = $this->pipes;
@@ -480,10 +481,6 @@ public function isRunning()
480481

481482
$this->updateStatus();
482483

483-
if ($this->processInformation['running'] === false) {
484-
$this->status = self::STATUS_TERMINATED;
485-
}
486-
487484
return $this->processInformation['running'];
488485
}
489486

@@ -506,6 +503,12 @@ public function stop($timeout=10)
506503
$time += 1000;
507504
usleep(1000);
508505
}
506+
507+
foreach ($this->pipes as $pipe) {
508+
fclose($pipe);
509+
}
510+
$this->pipes = array();
511+
509512
$exitcode = proc_close($this->process);
510513
$this->exitcode = -1 === $this->processInformation['exitcode'] ? $exitcode : $this->processInformation['exitcode'];
511514
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public function testProcessResponses($expected, $getter, $code)
5555
*/
5656
public function testProcessPipes($expected, $code)
5757
{
58-
if (strpos(PHP_OS, "WIN") === 0 && version_compare(phpversion(), "5.3.9", "<")) {
59-
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366');
58+
if (strpos(PHP_OS, "WIN") === 0) {
59+
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 and https://bugs.php.net/bug.php?id=51800');
6060
}
6161

6262
$p = new Process(sprintf('php -r %s', escapeshellarg($code)));
@@ -114,7 +114,11 @@ public function testStop()
114114
$this->assertTrue($process->isRunning());
115115
$process->stop();
116116
$this->assertFalse($process->isRunning());
117-
$this->assertTrue($process->hasBeenSignaled());
117+
118+
// skip this check on windows since it does not support signals
119+
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
120+
$this->assertTrue($process->hasBeenSignaled());
121+
}
118122
}
119123

120124
public function responsesCodeProvider()

0 commit comments

Comments
 (0)
0