Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b8a2e5d

Browse filesBrowse files
committed
minor symfony#7099 Clarify Process::wait() callback behaviour (Lilchef)
This PR was submitted for the 3.1 branch but it was merged into the 2.7 branch instead (closes symfony#7099). Discussion ---------- 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. I lost several hours after misunderstanding how this works and then trying to figure out why my 'after process' code was being triggered before the process had finished. Hopefully this change makes it clearer. Commits ------- d696a15 Clarify Process::wait() callback behaviour
2 parents 491cb13 + d696a15 commit b8a2e5d
Copy full SHA for b8a2e5d

File tree

Expand file treeCollapse file tree

1 file changed

+17
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+17
-6
lines changed

‎components/process.rst

Copy file name to clipboardExpand all lines: components/process.rst
+17-6Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,24 @@ are done doing other stuff::
113113
$process->start();
114114

115115
// ... do other things
116+
117+
$process->wait();
118+
119+
// ... do things after the process has finished
116120

121+
.. note::
122+
123+
The :method:`Symfony\\Component\\Process\\Process::wait` method is blocking,
124+
which means that your code will halt at this line until the external
125+
process is completed.
126+
127+
:method:`Symfony\\Component\\Process\\Process::wait` takes one optional argument:
128+
a callback that is called repeatedly whilst the process is still running, passing
129+
in the output and its type::
130+
131+
$process = new Process('ls -lsa');
132+
$process->start();
133+
117134
$process->wait(function ($type, $buffer) {
118135
if (Process::ERR === $type) {
119136
echo 'ERR > '.$buffer;
@@ -122,12 +139,6 @@ are done doing other stuff::
122139
}
123140
});
124141

125-
.. note::
126-
127-
The :method:`Symfony\\Component\\Process\\Process::wait` method is blocking,
128-
which means that your code will halt at this line until the external
129-
process is completed.
130-
131142
Stopping a Process
132143
------------------
133144

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.