Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[process] Added destructor to process to make sure handles are always…

… closed in the right order.
  • Loading branch information...
commit 9b5cfa883c8078b4c954734255050c0ee559775c 1 parent 6564115
@kimhemsoe kimhemsoe authored
Showing with 18 additions and 0 deletions.
  1. +6 −0 Process.php
  2. +12 −0 Tests/ProcessTest.php
View
6 Process.php
@@ -133,6 +133,12 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin
$this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
}
+ public function __destruct()
+ {
+ // stop() will check if we have a process running.
+ $this->stop();
+ }
+
/**
* Runs the process.
*
View
12 Tests/ProcessTest.php
@@ -121,6 +121,18 @@ public function testStop()
}
}
+ public function testPhpDeadlock()
+ {
+ $this->markTestSkipped('Can course php to hang');
+
+ // Sleep dont work as it will allow the process to handle signals and close
+ // file handles from the other end.
+ $process = new Process('php -r "while (true) {}"');
+ $process->start();
+
+ // PHP will deadlock when it tries to cleanup $process
+ }
+
public function responsesCodeProvider()
{
return array(
Please sign in to comment.
Something went wrong with that request. Please try again.