8000 [Process] Stop the process correctly even if underlying input stream … · symfony/symfony@c89132b · GitHub
[go: up one dir, main page]

Skip to content

Commit c89132b

Browse files
committed
[Process] Stop the process correctly even if underlying input stream is not closed:
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
1 parent ceb26c2 commit c89132b

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