Created
February 18, 2017 03:51
-
-
Save gong023/7c8266cab00d5948db8df7f2d0a74570 to your computer and use it in GitHub Desktop.
bug?
This file contains 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
<?php | |
$p = new Phar('test.phar', FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME); | |
$p->startBuffering(); | |
$stub = <<<STR | |
#!/usr/bin/env php | |
<?php | |
Phar::mapPhar(); | |
include "phar://test.phar/parent.php"; | |
__HALT_COMPILER(); | |
STR; | |
$p->setStub($stub); | |
$parent = <<<STR | |
<?php | |
\$descriptorspec = array( | |
0 => array("pipe", "r"), | |
1 => array("pipe", "w"), | |
2 => array("pipe", "w") | |
); | |
\$path = realpath(__DIR__ . '/child.php'); | |
\$process = proc_open('php ' . \$path, \$descriptorspec, \$pipes); | |
if (is_resource(\$process)) { | |
fclose(\$pipes[0]); | |
\$stdout = stream_get_contents(\$pipes[1]); | |
fclose(\$pipes[1]); | |
fclose(\$pipes[2]); | |
\$return_value = proc_close(\$process); | |
var_dump(\$stdout); | |
var_dump(\$return_value); | |
} | |
STR; | |
$p['parent.php'] = $parent; | |
$child = <<<STR | |
<?php | |
file_put_contents(sys_get_temp_dir() . '/child', "child"); | |
echo "child"; | |
STR; | |
$p['child.php'] = $child; | |
$p->stopBuffering(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment