10000 Clarify Process::wait() callback behaviour by Lilchef · Pull Request #7099 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

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 1 commit
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
Next Next commit
Clarify Process::wait() callback behaviour
There was no clear description of when the Process::wait() callback was triggered and it seemed like it would be called once the process was complete which is incorrect.
  • Loading branch information
Lilchef authored Oct 28, 2016
commit a352164d57cab430a84a9931080d65b18c11ecd9
25 changes: 18 additions & 7 deletions components/process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,26 @@ are done doing other stuff::

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this added trailing whitespace

// ... do other things

$process->wait();

// do things after the process has finished
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this to // ... 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
0