1
0
mirror of https://github.com/php/php-src.git synced 2026-03-28 02:02:32 +01:00
Files
archived-php-src/ext/standard/tests/general_functions/proc_open_null.phpt
Nikita Popov 6285bb52fa Support redirect+null descriptors in proc_open
This adds support for doing something like:

    [1 => ['pipe', 'w'], 2 => ['redirect', 1]]

This will make descriptor 2 on the child end a dup'd descriptor 1.
This is mainly useful in conjunction with shell-less mode, because
we don't have an easy way to do "2>&1" there.

Additionally we support:

    [1 => ['pipe', 'w'], 2 => ['null']]

Which would be the same as a >/dev/null or >nul redirect, depending
on platform.
2019-07-11 15:48:10 +02:00

31 lines
606 B
PHP

--TEST--
Null pipes in proc_open()
--FILE--
<?php
$php = getenv('TEST_PHP_EXECUTABLE');
$cmd = [$php, '-r', 'echo "Test"; fprintf(STDERR, "Error");'];
$proc = proc_open($cmd, [1 => ['null'], 2 => ['pipe', 'w']], $pipes);
var_dump($pipes);
var_dump(stream_get_contents($pipes[2]));
proc_close($proc);
$proc = proc_open($cmd, [1 => ['pipe', 'w'], 2 => ['null']], $pipes);
var_dump($pipes);
var_dump(stream_get_contents($pipes[1]));
proc_close($proc);
?>
--EXPECT--
array(1) {
[2]=>
resource(4) of type (stream)
}
string(5) "Error"
array(1) {
[1]=>
resource(6) of type (stream)
}
string(4) "Test"