File tree Expand file tree Collapse file tree 3 files changed +55
-7
lines changed
Filter options
Expand file tree Collapse file tree 3 files changed +55
-7
lines changed
Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ PHP NEWS
11
11
- Session:
12
12
. Fixed bug #69582 (session not readable by root in CLI). (EvgeniySpinov)
13
13
14
+ - Standard:
15
+ . Fixed bug #69442 (closing of fd incorrect when PTS enabled). (jaytaph)
16
+
14
17
19 Jan 2017 PHP 7.0.15
15
18
16
19
- Core:
Original file line number Diff line number Diff line change @@ -820,6 +820,12 @@ PHP_FUNCTION(proc_open)
820
820
}
821
821
#endif
822
822
823
+ #if PHP_CAN_DO_PTS
824
+ if (dev_ptmx >= 0 ) {
825
+ close (dev_ptmx );
826
+ close (slave_pty );
827
+ }
828
+ #endif
823
829
/* close those descriptors that we just opened for the parent stuff,
824
830
* dup new descriptors into required descriptors and close the original
825
831
* cruft */
@@ -835,13 +841,6 @@ PHP_FUNCTION(proc_open)
835
841
close (descriptors [i ].childend );
836
842
}
837
843
838
- #if PHP_CAN_DO_PTS
839
- if (dev_ptmx >= 0 ) {
840
- close (dev_ptmx );
841
- close (slave_pty );
842
- }
843
- #endif
844
-
845
844
if (cwd ) {
846
845
php_ignore_value (chdir (cwd ));
847
846
}
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ proc_open with PTY closes incorrect file descriptor
3
+ --SKIPIF--
4
+ <?php
5
+
6
+ $ code = <<< 'EOC'
7
+ <?php
8
+ $descriptors = array(array("pty"), array("pty"), array("pty"), array("pipe", "w"));
9
+ $pipes = array();
10
+ $process = proc_open('echo "foo";', $descriptors, $pipes);
11
+ EOC;
12
+
13
+ $ tmpFile = tempnam (sys_get_temp_dir (), "bug69442 " );
14
+ file_put_contents ($ tmpFile , $ code );
15
+
16
+ exec ($ _SERVER ['TEST_PHP_EXECUTABLE ' ]." " .$ tmpFile ." 2>&1 " , $ output );
17
+ $ output = join ("\n" , $ output );
18
+ unlink ($ tmpFile );
19
+
20
+ if (strstr ($ output , "pty pseudo terminal not supported on this system " ) !== false ) {
21
+ die ("skip PTY pseudo terminals are not supported " );
22
+ }
23
+ --FILE --
24
+ <?php
25
+ $ cmd = '(echo "foo" ; exit 42;) 3>/dev/null; code=$?; echo $code >&3; exit $code ' ;
26
+ $ descriptors = array (array ("pty " ), array ("pty " ), array ("pty " ), array ("pipe " , "w " ));
27
+ $ pipes = array ();
28
+
29
+ $ process = proc_open ($ cmd , $ descriptors , $ pipes );
30
+
31
+ foreach ($ pipes as $ type => $ pipe ) {
32
+ $ data = fread ($ pipe , 999 );
33
+ echo 'type ' . $ type . ' ' ;
34
+ var_dump ($ data );
35
+ fclose ($ pipe );
36
+ }
37
+ proc_close ($ process );
38
+ --EXPECT --
39
+ type 0 string(5 ) "foo
40
+ "
41
+ type 1 string (0 ) ""
42
+ type 2 string (0 ) ""
43
+ type 3 string (3 ) "42
44
+ "
45
+
46
+
You can’t perform that action at this time.
0 commit comments