8000 bug #50354 [Process] Stop the process correctly even if underlying in… · symfony/symfony@8c5f5ae · GitHub
[go: up one dir, main page]

Skip to content

Commit 8c5f5ae

Browse files
bug #50354 [Process] Stop the process correctly even if underlying input stream is not closed (joelwurtz)
This PR was merged into the 5.4 branch. Discussion ---------- [Process] Stop the process correctly even if underlying input stream is not closed | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | / | License | MIT | Doc PR | / While checking a process to end, on posix system, process component only checks if pipes are still open, this fix ensure that if the process is terminated it correctly return, even if the underlying pipe is not closed. It can be useful when using \STDIN as a input stream as it will always be open Commits ------- c89132b [Process] Stop the process correctly even if underlying input stream is not closed:
2 parents ceb26c2 + c89132b commit 8c5f5ae

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public function wait(callable $callback = null)
428428

429429
do {
430430
$this->checkTimeout();
431-
$running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
431+
$running = $this->isRunning() && ('\\' === \DIRECTORY_SEPARATOR || $this->processPipes->areOpen());
432432
$this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
433433
} while ($running);
434434

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,16 @@ public function testEnvCaseInsensitiveOnWindows()
15381538
}
15391539
}
15401540

1541+
public function testNotTerminableInputPipe()
1542+
{
1543+
$process = $this->getProcess('echo foo');
1544+
$process->setInput(\STDIN);
1545+
$process->start();
1546+
$process->setTimeout(2);
1547+
$process->wait();
1548+
$this->assertFalse($process->isRunning());
1549+
}
1550+
15411551
/**
15421552
* @param string|array $commandline
15431553
* @param mixed $input

0 commit comments

Comments
 (0)
0