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

Skip to content

Clarify Process::wait() callback behaviour #7099

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

Closed
wants to merge 2 commits into from
Closed
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
23 changes: 17 additions & 6 deletions components/process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,24 @@ are done doing other stuff::
$process->start();

// ... do other things

$process->wait();

// ... do things after the process has finished

.. note::

The :method:`Symfony\\Component\\Process\\Process::wait` method is blocking,
which means that your code will halt at this line until the external
process is completed.

:method:`Symfony\\Component\\Process\\Process::wait` takes one optional argument:
a callback that is called repeatedly whilst the process is still running, passing
in the output and its type::

$process = new Process('ls -lsa');
$process->start();

$process->wait(function ($type, $buffer) {
if (Process::ERR === $type) {
echo 'ERR > '.$buffer;
Expand All @@ -141,12 +158,6 @@ are done doing other stuff::
}
});

.. note::

The :method:`Symfony\\Component\\Process\\Process::wait` method is blocking,
which means that your code will halt at this line until the external
process is completed.

Streaming to the Standard Input of a Process
--------------------------------------------

Expand Down