mirror of
https://github.com/danog/parallel.git
synced 2025-01-22 14:01:14 +01:00
Close stream and process before resolving delayed
This commit is contained in:
parent
85e730f4f0
commit
c9b9aa148f
@ -182,10 +182,11 @@ class Process implements ProcessContext
|
||||
|
||||
$this->poll = Loop\poll($stream, function ($resource) {
|
||||
if (!is_resource($resource) || feof($resource)) {
|
||||
$this->close($resource);
|
||||
$this->delayed->reject(new ProcessException('Process ended unexpectedly.'));
|
||||
} else {
|
||||
$code = fread($resource, 1);
|
||||
|
||||
$this->close($resource);
|
||||
if (!strlen($code) || !is_numeric($code)) {
|
||||
$this->delayed->reject(new ProcessException('Process ended without providing a status code.'));
|
||||
} else {
|
||||
@ -193,6 +194,17 @@ class Process implements ProcessContext
|
||||
}
|
||||
}
|
||||
|
||||
$this->poll->free();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the stream resource provided, the open process handle, and stdin.
|
||||
*
|
||||
* @param resource $resource
|
||||
*/
|
||||
private function close($resource)
|
||||
{
|
||||
if (is_resource($resource)) {
|
||||
fclose($resource);
|
||||
}
|
||||
@ -203,8 +215,6 @@ class Process implements ProcessContext
|
||||
}
|
||||
|
||||
$this->stdin->close();
|
||||
$this->poll->free();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user