From a352164d57cab430a84a9931080d65b18c11ecd9 Mon Sep 17 00:00:00 2001 From: Aaron Baker Date: Fri, 28 Oct 2016 19:27:57 +0100 Subject: [PATCH 1/2] 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. --- components/process.rst | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/components/process.rst b/components/process.rst index 8444905285f..c4e4dbd870d 100644 --- a/components/process.rst +++ b/components/process.rst @@ -130,9 +130,26 @@ are done doing other stuff:: $process = new Process('ls -lsa'); $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; @@ -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 -------------------------------------------- From 5629fc868756aaa51384ee19c99c648c1f2987fd Mon Sep 17 00:00:00 2001 From: Aaron Baker Date: Tue, 1 Nov 2016 20:00:26 +0000 Subject: [PATCH 2/2] Made comment in wait() example consistent with previous ones Also removed unintended extra whitespace --- components/process.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/process.rst b/components/process.rst index c4e4dbd870d..7bb6b4a9c89 100644 --- a/components/process.rst +++ b/components/process.rst @@ -130,12 +130,12 @@ are done doing other stuff:: $process = new Process('ls -lsa'); $process->start(); - + // ... do other things $process->wait(); - // do things after the process has finished + // ... do things after the process has finished .. note::