summaryrefslogtreecommitdiff
path: root/ext/standard/tests/file
diff options
context:
space:
mode:
authorJoe Watkins <krakjoe@php.net>2017-01-06 06:57:35 +0000
committerJoe Watkins <krakjoe@php.net>2017-01-06 06:58:56 +0000
commite86d355c4c828be63fbccb24ba60cb08310408e8 (patch)
tree5d1560bf5e60d7af229eccba868d438daa7a5c49 /ext/standard/tests/file
parent811dfaa57b914630e1805c96f3fed83ecc97cc45 (diff)
parentff6b309c6f4c26ffedd5fc9e4cd021b7300617a3 (diff)
downloadphp-git-e86d355c4c828be63fbccb24ba60cb08310408e8.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Fixed #69442 closing of fd incorrect when PTS enabled
Diffstat (limited to 'ext/standard/tests/file')
-rw-r--r--ext/standard/tests/file/bug69442.phpt46
1 files changed, 46 insertions, 0 deletions
diff --git a/ext/standard/tests/file/bug69442.phpt b/ext/standard/tests/file/bug69442.phpt
new file mode 100644
index 0000000000..e5255acb37
--- /dev/null
+++ b/ext/standard/tests/file/bug69442.phpt
@@ -0,0 +1,46 @@
+--TEST--
+proc_open with PTY closes incorrect file descriptor
+--SKIPIF--
+<?php
+
+$code = <<< 'EOC'
+ <?php
+ $descriptors = array(array("pty"), array("pty"), array("pty"), array("pipe", "w"));
+ $pipes = array();
+ $process = proc_open('echo "foo";', $descriptors, $pipes);
+EOC;
+
+ $tmpFile = tempnam(sys_get_temp_dir(), "bug69442");
+ file_put_contents($tmpFile, $code);
+
+ exec($_SERVER['TEST_PHP_EXECUTABLE']." ".$tmpFile." 2>&1", $output);
+ $output = join("\n", $output);
+ unlink($tmpFile);
+
+ if (strstr($output, "pty pseudo terminal not supported on this system") !== false) {
+ die("skip PTY pseudo terminals are not supported");
+ }
+--FILE--
+<?php
+$cmd = '(echo "foo" ; exit 42;) 3>/dev/null; code=$?; echo $code >&3; exit $code';
+$descriptors = array(array("pty"), array("pty"), array("pty"), array("pipe", "w"));
+$pipes = array();
+
+$process = proc_open($cmd, $descriptors, $pipes);
+
+foreach ($pipes as $type => $pipe) {
+ $data = fread($pipe, 999);
+ echo 'type ' . $type . ' ';
+ var_dump($data);
+ fclose($pipe);
+}
+proc_close($process);
+--EXPECT--
+type 0 string(5) "foo
+"
+type 1 string(0) ""
+type 2 string(0) ""
+type 3 string(3) "42
+"
+
+