Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b5e3576

Browse files
committed
[Process] Fix latest merge from 2.2 in 2.3
1 parent 77a961d commit b5e3576

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -298,21 +298,18 @@ public function wait($callback = null)
298298
if (null !== $callback) {
299299
$this->callback = $this->buildCallback($callback);
300300
}
301-
301+
302302
do {
303303
$this->checkTimeout();
304304
$running = defined('PHP_WINDOWS_VERSION_BUILD') ? $this->isRunning() : $this->processPipes->hasOpenHandles();
305305
$close = !defined('PHP_WINDOWS_VERSION_BUILD') || !$running;;
306306
$this->readPipes(true, $close);
307307
} while ($running);
308-
308+
309309
while ($this->isRunning()) {
310310
usleep(1000);
311311
}
312312

313-
$this->processPipes->close();
314-
$exitcode = proc_close($this->process);
315-
316313
if ($this->processInformation['signaled']) {
317314
if ($this->isSigchildEnabled()) {
318315
throw new RuntimeException('The process has been signaled.');
@@ -1043,7 +1040,7 @@ private function readPipes($blocking, $close)
10431040
} else {
10441041
$result = $this->processPipes->read($blocking);
10451042
}
1046-
1043+
10471044
foreach ($result as $type => $data) {
10481045
if (3 == $type) {
10491046
$this->fallbackExitcode = (int) $data;
@@ -1073,27 +1070,11 @@ private function close()
10731070
{
10741071
$exitcode = -1;
10751072

1073+
$this->processPipes->close();
10761074
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();
10801075
$exitcode = proc_close($this->process);
10811076
}
10821077

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-
10971078
$this->exitcode = $this->exitcode !== null ? $this->exitcode : -1;
10981079
$this->exitcode = -1 != $exitcode ? $exitcode : $this->exitcode;
10991080

0 commit comments

Comments
 (0)