[process] Added destructor to process to make sure handles are always closed in the right order.

This commit is contained in:
Kim Hemsø Rasmussen 2012-04-11 23:08:57 +02:00
parent b47cb35e7b
commit 89a5c1a845
2 changed files with 18 additions and 0 deletions

View File

@ -133,6 +133,12 @@ class Process
$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 File

@ -121,6 +121,18 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
}
}
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(