proc_open is phar doesn't work?

From: Date: Sun, 26 Feb 2017 10:26:57 +0000
Subject: proc_open is phar doesn't work?
Groups: php.general 
Request: Send a blank email to php-general+get-326000@lists.php.net to get a copy of this message
hello, I have problem using proc_open in phar file. here is sample code <?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(); I expect /tmp/child file is created by child.php and 1 is set to $stdout as status code. but actually child.php seems not to be executed and I get 0 as exit code. as long as reading php-src and debugging, I find php tries to execl 'php phar://test.phar/child.php' at here https://github.com/php/php-src/blob/0ca4358ade18c3839414580da35660c6e9be08d5/ext/standard/proc_open.c#L842 of course it shouldn't work because php cannot execute phar://... independently. so does proc_open in phar never work? I'm not sure although I find some evidences. I cannot believe no one has not tried to use proc_open in phar until now... according to git history, this code has not been changed at least 2 years. is my understanding correct? if so, is there any workaround?

« previous php.general (#326000) next »