diff --git a/components/process.rst b/components/process.rst index f2e61fdabbe..2351e7e9183 100644 --- a/components/process.rst +++ b/components/process.rst @@ -257,6 +257,28 @@ When running a program asynchronously, you can send it posix signals with the POSIX signals are not available on Windows platforms, please refer to the `PHP documentation`_ for available signals. +Redirecting output to /dev/null +------------------------------ + +.. versionadded:: 2.5 + The :method:`Symfony\\Component\\Process\\Process::setProcessPipes` method was introduced in Symfony 2.4. + +Occasionally the output of a process is not important because you are +communicating with it via other means. In these cases it can be helpful +to redirect the output to `/dev/null`` to avoid blocking on full pipes. + + +.. code-block:: php + + use Symfony\Component\Process\Process; + use Symfony\Component\Process\NullProcessPipes; + + $process = new Process('find / -name "rabbit"'); + $process->setProcessPipes(new NullProcessPipes()); + $process->run(); + + $process->getOutput(); // Will be empty, but this process will never block on output! + Process Pid -----------