@@ -50,6 +50,25 @@ the contents of the output and
5050:method: `Symfony\\ Component\\ Process\\ Process::clearErrorOutput ` clears
5151the contents of the error output.
5252
53+ .. versionadded :: 2.5
54+ The ``mustRun() `` method was introduced in Symfony 2.5.
55+
56+ With Symfony 2.5, you can use the :method: `Symfony\\ Component\\ Process\\ Process::mustRun `
57+ method which throws a :class: `Symfony\\ Component\\ Process\\ Exception\\ ProcessFailedException `
58+ when the process couldn't be executed successfully::
59+
60+ use Symfony\Component\Process\Exception\ProcessFailedException;
61+ use Symfony\Component\Process\Process;
62+
63+ $process = new Process('ls -lsa');
64+
65+ try {
66+ $process->mustRun();
67+ print $process->getOutput();
68+ } catch (ProcessFailedException $e) {
69+ print $process->getErrorOutput();
70+ }
71+
5372Getting real-time Process Output
5473--------------------------------
5574
@@ -218,17 +237,17 @@ Process Idle Timeout
218237.. versionadded :: 2.4
219238 The :method: `Symfony\\ Component\\ Process\\ Process::setIdleTimeout ` method
220239 was introduced in Symfony 2.4.
221-
240+
222241In contrast to the timeout of the previous paragraph, the idle timeout only
223242considers the time since the last output was produced by the process::
224243
225244 use Symfony\Component\Process\Process;
226-
245+
227246 $process = new Process('something-with-variable-runtime');
228247 $process->setTimeout(3600);
229248 $process->setIdleTimeout(60);
230249 $process->run();
231-
250+
232251In the case above, a process is considered timed out, when either the total runtime
233252exceeds 3600 seconds, or the process does not produce any output for 60 seconds.
234253
0 commit comments