8000 [Process] Stop the process correctly even if underlying input stream is not closed by joelwurtz · Pull Request #50354 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Process] Stop the process correctly even if underlying input stream is not closed #50354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[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
  • Loading branch information
joelwurtz committed May 17, 2023
commit c89132bac4c607faaf871727d299490c15dec909
2 changes: 1 addition & 1 deletion src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public function wait(callable $callback = null)

do {
$this->checkTimeout();
$running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
$running = $this->isRunning() && ('\\' === \DIRECTORY_SEPARATOR || $this->processPipes->areOpen());
$this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
} while ($running);

Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Process/Tests/ProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,16 @@ public function testEnvCaseInsensitiveOnWindows()
}
}

public function testNotTerminableInputPipe()
{
$process = $this->getProcess('echo foo');
$process->setInput(\STDIN);
$process->start();
$process->setTimeout(2);
$process->wait();
$this->assertFalse($process->isRunning());
}

/**
* @param string|array $commandline
* @param mixed $input
Expand Down
0