Fixed system interpreter leaked issue #1134.#1135
Closed
markwu wants to merge 3 commits into
Closed
Conversation
Use exec() to run php code with used interpreter instead of system interpreter.
Contributor
Author
|
The result: |
Contributor
Author
|
|
Contributor
Author
|
I try to wrap the function, so I can get the function call through used php interpreter like following. We can get exact the same result as before. UsePhpFunctionWrapper::execute('php_ini_loaded_file()', $output) ? $file = $output : $file = '';<?php
namespace PhpBrew;
use PhpBrew\Config;
class UsePhpFunctionWrapper
{
public static function execute($func, &$output = null)
{
$retVal = false;
$command = Config::getCurrentPhpBin() . '/php';
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
$process = proc_open($command, $descriptorspec, $pipes);
if (is_resource($process)) {
fwrite($pipes[0], '<?php echo serialize(' . $func .'); ?>');
fclose($pipes[0]);
$output = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$retVal = proc_close($process);
if ($retVal === 0) {
$output = unserialize($output);
return true;
}
}
return false;
}
} |
Contributor
Author
|
|
Contributor
|
This looks even more complicated than I thought it would. We can do it much simpler:
|
Contributor
Author
|
Yes, you are right, it's much simpler. I just tried to keep everything as before. But, I am not so familiar with the shell scripts. I will leave the implement for you, and see If I can catch how you do it. |
Contributor
|
Closing in favor of #1136. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use exec() to run php code with used interpreter instead of system interpreter.