<?php
if ($argc > 1) {
var_dump($argv);
} else {
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
);
$proc = proc_open("php " . escapeshellarg($argv[0]) . " args lel", $descriptorspec, $pipes);
fclose($pipes[0]); // default-inherited-stdin creeps me out
while (proc_get_status($proc)['running']) {
usleep(100 * 1000);
}
var_dump('stdout: ', stream_get_contents($pipes[1]));
fclose($pipes[1]);
proc_close($proc);
}
Fatal error: Uncaught Error: Call to undefined function proc_open() in /in/4uC8n:9
Stack trace:
#0 {main}
thrown in /in/4uC8n on line 9
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Fatal error: Uncaught Error: Call to undefined function proc_open() in /in/4uC8n:9
Stack trace:
#0 {main}
thrown in /in/4uC8n on line 9
Process exited with code 255.
Output for 8.0.13
fork has been disabled for security reasons
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.33
fork has been disabled for security reasons
Process exited with code 127.
Output for 7.4.0 - 7.4.32
Notice: Undefined variable: pipes in /in/4uC8n on line 9
Warning: proc_open() has been disabled for security reasons in /in/4uC8n on line 9
Notice: Undefined variable: pipes in /in/4uC8n on line 10
Notice: Trying to access array offset on value of type null in /in/4uC8n on line 10
Warning: fclose() expects parameter 1 to be resource, null given in /in/4uC8n on line 10
Warning: proc_get_status() expects parameter 1 to be resource, null given in /in/4uC8n on line 11
Notice: Trying to access array offset on value of type bool in /in/4uC8n on line 11
Notice: Undefined variable: pipes in /in/4uC8n on line 14
Notice: Trying to access array offset on value of type null in /in/4uC8n on line 14
Warning: stream_get_contents() expects parameter 1 to be resource, null given in /in/4uC8n on line 14
string(8) "stdout: "
bool(false)
Notice: Undefined variable: pipes in /in/4uC8n on line 15
Notice: Trying to access array offset on value of type null in /in/4uC8n on line 15
Warning: fclose() expects parameter 1 to be resource, null given in /in/4uC8n on line 15
Warning: proc_close() expects parameter 1 to be resource, null given in /in/4uC8n on line 16
Output for 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
Notice: Undefined variable: pipes in /in/4uC8n on line 9
Warning: proc_open() has been disabled for security reasons in /in/4uC8n on line 9
Notice: Undefined variable: pipes in /in/4uC8n on line 10
Warning: fclose() expects parameter 1 to be resource, null given in /in/4uC8n on line 10
Warning: proc_get_status() expects parameter 1 to be resource, null given in /in/4uC8n on line 11
Notice: Undefined variable: pipes in /in/4uC8n on line 14
Warning: stream_get_contents() expects parameter 1 to be resource, null given in /in/4uC8n on line 14
string(8) "stdout: "
bool(false)
Notice: Undefined variable: pipes in /in/4uC8n on line 15
Warning: fclose() expects parameter 1 to be resource, null given in /in/4uC8n on line 15
Warning: proc_close() expects parameter 1 to be resource, null given in /in/4uC8n on line 16