@@ -83,7 +83,7 @@ public function start() : void {
83
83
throw new Exceptions \ServerException ("Failed to start server. Is something already running on port {$ this ->port }? " );
84
84
}
85
85
86
- register_shutdown_function (function () {
86
+ register_shutdown_function (function () {
87
87
if ( $ this ->isRunning () ) {
88
88
$ this ->stop ();
89
89
}
@@ -287,8 +287,17 @@ private function startServer( string $fullCmd ) {
287
287
$ env = null ;
288
288
$ cwd = null ;
289
289
290
- $ output = tmpfile ();
291
- $ process = proc_open ($ fullCmd , [fopen ('php://stdin ' , 'r ' ), $ output , $ output ], $ pipes , $ cwd , $ env , [
290
+ $ stdin = fopen ('php://stdin ' , 'rb ' );
291
+ $ stdoutf = tempnam (sys_get_temp_dir (), 'MockWebServer.stdout ' );
292
+ $ stderrf = tempnam (sys_get_temp_dir (), 'MockWebServer.stderr ' );
293
+
294
+ $ descriptorSpec = [
295
+ 0 => $ stdin ,
296
+ 1 => [ 'file ' , $ stdoutf , 'a ' ],
297
+ 2 => [ 'file ' , $ stderrf , 'a ' ],
298
+ ];
299
+
300
+ $ process = proc_open ($ fullCmd , $ descriptorSpec , $ pipes , $ cwd , $ env , [
292
301
'suppress_errors ' => false ,
293
302
'bypass_shell ' => true ,
294
303
]);
@@ -297,7 +306,7 @@ private function startServer( string $fullCmd ) {
297
306
return $ process ;
298
307
}
299
308
300
- throw new Exceptions \ServerException (" Error starting server " );
309
+ throw new Exceptions \ServerException (' Error starting server ' );
301
310
}
302
311
303
312
}
0 commit comments