I had an issue reported to my package donatj/mock-webserver
that turned out to be caused by this package.
donatj/mock-webserver#59 (comment)
After poking @sigma-z's example a bit, I've determined there's some sort of problem with this using this library AND generating file descriptors that can be passed to sub processes with proc_open
.
I've boiled an example of the problem down to:
<?php
require __DIR__ . '/vendor/autoload.php';
DG\BypassFinals::enable();
$stdin = fopen('php://stdin', 'rb');
$stdoutf = tempnam(sys_get_temp_dir(), 'dgb.test');
$descriptorSpec = [
0 => $stdin,
1 => [ 'file', $stdoutf, 'a' ],
];
$fullCmd = 'echo "This should come LAST in the output"';
$process = proc_open($fullCmd, $descriptorSpec, $pipes);
sleep(1);
echo "=== Text should come AFTER this line not before... reading from {$stdoutf} ===\n";
echo file_get_contents($stdoutf);
If you run this, you get something like
dup2: Bad file descriptor
This should come LAST in the output
=== Text should come AFTER this line not before... reading from <path> ===
If you comment out the line DG\BypassFinals::enable();
though you get the expected
=== Text should come AFTER this line not before... reading from /private/var/folders/dr/cpm01_51333c1px2yzc8qr9xq1kth0/T/dgb.testx1XyaY ===
This should come LAST in the output
It's failing to either create or pass the file descriptor to the subprocess.
I seem to be able to solve it on my site by replacing the line
1 => [ 'file', $stdoutf, 'a' ],
with
1 => fopen($stdoutf, 'wb'),
and I very well might do that but I still think this likely calls for some investigation