@@ -298,21 +298,18 @@ public function wait($callback = null)
298
298
if (null !== $ callback ) {
299
299
$ this ->callback = $ this ->buildCallback ($ callback );
300
300
}
301
-
301
+
302
302
do {
303
303
$ this ->checkTimeout ();
304
304
$ running = defined ('PHP_WINDOWS_VERSION_BUILD ' ) ? $ this ->isRunning () : $ this ->processPipes ->hasOpenHandles ();
305
305
$ close = !defined ('PHP_WINDOWS_VERSION_BUILD ' ) || !$ running ;;
306
306
$ this ->readPipes (true , $ close );
307
307
} while ($ running );
308
-
308
+
309
309
while ($ this ->isRunning ()) {
310
310
usleep (1000 );
311
311
}
312
312
313
- $ this ->processPipes ->close ();
314
- $ exitcode = proc_close ($ this ->process );
315
-
316
313
if ($ this ->processInformation ['signaled ' ]) {
317
314
if ($ this ->isSigchildEnabled ()) {
318
315
throw new RuntimeException ('The process has been signaled. ' );
@@ -1043,7 +1040,7 @@ private function readPipes($blocking, $close)
1043
1040
} else {
1044
1041
$ result = $ this ->processPipes ->read ($ blocking );
1045
1042
}
1046
-
1043
+
1047
1044
foreach ($ result as $ type => $ data ) {
1048
1045
if (3 == $ type ) {
1049
1046
$ this ->fallbackExitcode = (int ) $ data ;
@@ -1073,27 +1070,11 @@ private function close()
1073
1070
{
1074
1071
$ exitcode = -1 ;
1075
1072
1073
+ $ this ->processPipes ->close ();
1076
1074
if (is_resource ($ this ->process )) {
1077
- // Unix pipes must be closed before calling proc_close to void deadlock
1078
- // see manual http://php.net/manual/en/function.proc-close.php
1079
- $ this ->processPipes ->closeUnixPipes ();
1080
1075
$ exitcode = proc_close ($ this ->process );
1081
1076
}
1082
1077
1083
- // Windows only : when using file handles, some activity may occur after
1084
- // calling proc_close
1085
- while ($ this ->processPipes ->hasOpenHandles ()) {
1086
- usleep (100 );
1087
- foreach ($ this ->processPipes ->readAndCloseHandles (true ) as $ type => $ data ) {
1088
- if (3 == $ type ) {
1089
- $ this ->fallbackExitcode = (int ) $ data ;
1090
- } else {
1091
- call_user_func ($ this ->callback , $ type === self ::STDOUT ? self ::OUT : self ::ERR , $ data );
1092
- }
1093
- }
1094
- }
1095
- $ this ->processPipes ->close ();
1096
-
1097
1078
$ this ->exitcode = $ this ->exitcode !== null ? $ this ->exitcode : -1 ;
1098
1079
$ this ->exitcode = -1 != $ exitcode ? $ exitcode : $ this ->exitcode ;
1099
1080
0 commit comments