Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit 127cff0aa8b2a6f7e388f180e471f748e6a1dec3 2 parents d694858 + 6dca141
Fabien Potencier fabpot authored
13 src/Symfony/Component/Process/Process.php
@@ -213,14 +213,15 @@ public function start($callback = null)
213 213
214 214 if (null === $this->stdin) {
215 215 fclose($this->pipes[0]);
  216 + unset($this->pipes[0]);
216 217
217 218 return;
218 219 } else {
219 220 $writePipes = array($this->pipes[0]);
  221 + unset($this->pipes[0]);
220 222 $stdinLen = strlen($this->stdin);
221 223 $stdinOffset = 0;
222 224 }
223   - unset($this->pipes[0]);
224 225
225 226 while ($writePipes) {
226 227 $r = $this->pipes;
@@ -480,10 +481,6 @@ public function isRunning()
480 481
481 482 $this->updateStatus();
482 483
483   - if ($this->processInformation['running'] === false) {
484   - $this->status = self::STATUS_TERMINATED;
485   - }
486   -
487 484 return $this->processInformation['running'];
488 485 }
489 486
@@ -506,6 +503,12 @@ public function stop($timeout=10)
506 503 $time += 1000;
507 504 usleep(1000);
508 505 }
  506 +
  507 + foreach ($this->pipes as $pipe) {
  508 + fclose($pipe);
  509 + }
  510 + $this->pipes = array();
  511 +
509 512 $exitcode = proc_close($this->process);
510 513 $this->exitcode = -1 === $this->processInformation['exitcode'] ? $exitcode : $this->processInformation['exitcode'];
511 514 }
10 src/Symfony/Component/Process/Tests/ProcessTest.php
@@ -55,8 +55,8 @@ public function testProcessResponses($expected, $getter, $code)
55 55 */
56 56 public function testProcessPipes($expected, $code)
57 57 {
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');
60 60 }
61 61
62 62 $p = new Process(sprintf('php -r %s', escapeshellarg($code)));
@@ -114,7 +114,11 @@ public function testStop()
114 114 $this->assertTrue($process->isRunning());
115 115 $process->stop();
116 116 $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 + }
118 122 }
119 123
120 124 public function responsesCodeProvider()

0 comments on commit 127cff0

Please sign in to comment.
Something went wrong with that request. Please try again.