16
16
use function is_array ;
17
17
use function is_resource ;
18
18
use function proc_close ;
19
- use function proc_get_status ;
20
19
use function proc_open ;
21
- use function rewind ;
22
20
use function stream_get_contents ;
23
21
use function sys_get_temp_dir ;
24
22
use function tempnam ;
25
- use function time_nanosleep ;
26
23
use function unlink ;
27
24
use PHPUnit \Framework \Exception ;
28
25
@@ -57,14 +54,6 @@ public function runJob(string $job, array $settings = []): array
57
54
return $ this ->runProcess ($ job , $ settings );
58
55
}
59
56
60
- /**
61
- * Returns an array of file handles to be used in place of pipes.
62
- */
63
- protected function getHandles (): array
64
- {
65
- return [];
66
- }
67
-
68
57
/**
69
58
* Handles creating the child process and returning the STDOUT and STDERR.
70
59
*
@@ -75,8 +64,6 @@ protected function getHandles(): array
75
64
*/
76
65
protected function runProcess (string $ job , array $ settings ): array
77
66
{
78
- $ handles = $ this ->getHandles ();
79
-
80
67
$ env = null ;
81
68
82
69
if ($ this ->env ) {
@@ -92,9 +79,9 @@ protected function runProcess(string $job, array $settings): array
92
79
}
93
80
94
81
$ pipeSpec = [
95
- 0 => $ handles [ 0 ] ?? ['pipe ' , 'r ' ],
96
- 1 => $ handles [ 1 ] ?? ['pipe ' , 'w ' ],
97
- 2 => $ handles [ 2 ] ?? ['pipe ' , 'w ' ],
82
+ 0 => ['pipe ' , 'r ' ],
83
+ 1 => ['pipe ' , 'w ' ],
84
+ 2 => ['pipe ' , 'w ' ],
98
85
];
99
86
100
87
if ($ this ->stderrRedirection ) {
@@ -121,10 +108,6 @@ protected function runProcess(string $job, array $settings): array
121
108
122
109
fclose ($ pipes [0 ]);
123
110
124
- while (proc_get_status ($ process )['running ' ] === true ) {
125
- time_nanosleep (0 , 100000 );
126
- }
127
-
128
111
$ stderr = $ stdout = '' ;
129
112
130
113
if (isset ($ pipes [1 ])) {
@@ -139,22 +122,6 @@ protected function runProcess(string $job, array $settings): array
139
122
fclose ($ pipes [2 ]);
140
123
}
141
124
142
- if (isset ($ handles [1 ])) {
143
- rewind ($ handles [1 ]);
144
-
145
- $ stdout = stream_get_contents ($ handles [1 ]);
146
-
147
- fclose ($ handles [1 ]);
148
- }
149
-
150
- if (isset ($ handles [2 ])) {
151
- rewind ($ handles [2 ]);
152
-
153
- $ stderr = stream_get_contents ($ handles [2 ]);
154
-
155
- fclose ($ handles [2 ]);
156
- }
157
-
158
125
proc_close ($ process );
159
126
160
127
$ this ->cleanup ();
0 commit comments