Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[process] Added destructor to process to make sure handles are always…
… closed in the right order.
  • Loading branch information
kimhemsoe committed Apr 11, 2012
1 parent 6564115 commit 9b5cfa8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Process.php
Expand Up @@ -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); $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. * Runs the process.
* *
Expand Down
12 changes: 12 additions & 0 deletions Tests/ProcessTest.php
Expand Up @@ -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() public function responsesCodeProvider()
{ {
return array( return array(
Expand Down

0 comments on commit 9b5cfa8

Please sign in to comment.