I encountered an edge case where I don't want Process to perform fclose($this-pipes[0]) in Symfony\Component\Process\Pipes\AbstractPipes::write (line 161 in my copy, using Symfony 6.3) - the unset that follows it is fine.
Currently I work around this problem like this:
$p = new Process(...$args);
$p->setInput((function () {
while (true) {
yield "";
}
})());
Is there a better way to achieve the same result?
The specific case
docker compose exec --no-TTY and docker exec -i exit early, even though the underlying command is still running (and producing output) if stdin is closed. (clarification: docker exec without -i exits early as normal behaviour, so that's why I mentioned the version that does take the -i parameter)
There is a slightly better way:
If I don't
->write()anything to the stream object, its behaviour is identical to my generator in the question text.