[Process] Close unix pipes before calling proc_close
to avoid a deadlock
see http://php.net/manual/en/function.proc-close.php
This commit is contained in:
parent
6ec2cbaa6c
commit
37102dcc7c
@ -310,8 +310,13 @@ class Process
|
|||||||
}
|
}
|
||||||
$this->updateStatus(false);
|
$this->updateStatus(false);
|
||||||
|
|
||||||
|
// Unix pipes must be closed before calling proc_close to void deadlock
|
||||||
|
// see manual http://php.net/manual/en/function.proc-close.php
|
||||||
|
$this->processPipes->closeUnixPipes();
|
||||||
$exitcode = proc_close($this->process);
|
$exitcode = proc_close($this->process);
|
||||||
|
|
||||||
|
// Windows only : when using file handles, some activity may occur after
|
||||||
|
// calling proc_close
|
||||||
while($this->processPipes->hasOpenHandles()) {
|
while($this->processPipes->hasOpenHandles()) {
|
||||||
usleep(100);
|
usleep(100);
|
||||||
foreach ($this->processPipes->readAndCloseHandles(true) as $type => $data) {
|
foreach ($this->processPipes->readAndCloseHandles(true) as $type => $data) {
|
||||||
|
@ -77,14 +77,24 @@ class ProcessPipes
|
|||||||
*/
|
*/
|
||||||
public function close()
|
public function close()
|
||||||
{
|
{
|
||||||
foreach ($this->pipes as $offset => $pipe) {
|
$this->closeUnixPipes();
|
||||||
fclose($pipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->fileHandles as $offset => $handle) {
|
foreach ($this->fileHandles as $offset => $handle) {
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
}
|
}
|
||||||
$this->fileHandles = $this->pipes = array();
|
$this->fileHandles = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes unix pipes.
|
||||||
|
*
|
||||||
|
* Nothing happens in case file handles are used.
|
||||||
|
*/
|
||||||
|
public function closeUnixPipes()
|
||||||
|
{
|
||||||
|
foreach ($this->pipes as $pipe) {
|
||||||
|
fclose($pipe);
|
||||||
|
}
|
||||||
|
$this->pipes = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user