@@ -6,6 +6,7 @@ $php = getenv('TEST_PHP_EXECUTABLE');
6
6
if (!$ php ) {
7
7
die ("skip No php executable defined \n" );
8
8
}
9
+ if (PHP_OS_FAMILY === 'Windows ' ) die ('skip not for Windows ' );
9
10
?>
10
11
--FILE--
11
12
<?php
@@ -16,7 +17,7 @@ $php = getenv('TEST_PHP_EXECUTABLE');
16
17
if (!$ php ) {
17
18
die ("No php executable defined \n" );
18
19
}
19
- $ cmd = ' php -r "fwrite(STDOUT, $in = file_get_contents( \'php://stdin \')); fwrite(STDERR, $in);" ' ;
20
+ $ cmd = $ php . ' -r "\ $in = file_get_contents( \'php://stdin \'); fwrite(STDOUT, \$in ); fwrite(STDERR, \ $in);" ' ;
20
21
$ descriptors = array (array ('pipe ' , 'r ' ), array ('pipe ' , 'w ' ), array ('pipe ' , 'w ' ));
21
22
$ stdin = str_repeat ('* ' , 2049 );
22
23
@@ -32,6 +33,7 @@ $stdinOffset = 0;
32
33
33
34
unset($ pipes [0 ]);
34
35
36
+ $ procOutput = [];
35
37
while ($ pipes || $ writePipes ) {
36
38
$ r = $ pipes ;
37
39
$ w = $ writePipes ;
@@ -48,6 +50,8 @@ while ($pipes || $writePipes) {
48
50
$ written = fwrite ($ writePipes [0 ], substr ($ stdin , $ stdinOffset ), 8192 );
49
51
if (false !== $ written ) {
50
52
$ stdinOffset += $ written ;
53
+ } else {
54
+ die ('Failed to write to pipe ' );
51
55
}
52
56
if ($ stdinOffset >= $ stdinLen ) {
53
57
fclose ($ writePipes [0 ]);
@@ -58,12 +62,21 @@ while ($pipes || $writePipes) {
58
62
foreach ($ r as $ pipe ) {
59
63
$ type = array_search ($ pipe , $ pipes );
60
64
$ data = fread ($ pipe , 8192 );
61
- if (false === $ data || feof ($ pipe )) {
65
+ if (feof ($ pipe )) {
62
66
fclose ($ pipe );
63
67
unset($ pipes [$ type ]);
68
+ } elseif (false === $ data ) {
69
+ die ('Failed to read from pipe ' );
70
+ } else {
71
+ $ procOutput [$ type ] = ($ procOutput [$ type ] ?? '' ) . $ data ;
64
72
}
65
73
}
66
74
}
75
+ foreach ($ procOutput as $ output ) {
76
+ if ($ output !== $ stdin ) {
77
+ die ('Output does not match input: ' . $ output );
78
+ }
79
+ }
67
80
echo "OK. " ;
68
81
?>
69
82
--EXPECT--
0 commit comments