From 0743a760bc4eb2360aa2af5118a9f5252339c60b Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 9 Dec 2013 19:20:35 +1100 Subject: [PATCH 1/2] Documentation for setProcessPipes() | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes | Applies to | 2.4 | Fixed tickets | 9007 --- components/process.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/components/process.rst b/components/process.rst index f2e61fdabbe..df8db8dad9d 100644 --- a/components/process.rst +++ b/components/process.rst @@ -257,6 +257,24 @@ 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.4The ``setProcessPipes`` method was added 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. + + + 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 ----------- From 43bca2e0b99fbcb0c231049f23d783aa520b5a48 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 10 Dec 2013 10:11:16 +1100 Subject: [PATCH 2/2] Review feedback from WouterJ --- components/process.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/process.rst b/components/process.rst index df8db8dad9d..2351e7e9183 100644 --- a/components/process.rst +++ b/components/process.rst @@ -259,21 +259,25 @@ When running a program asynchronously, you can send it posix signals with the Redirecting output to /dev/null ------------------------------ -.. versionadded:: 2.4The ``setProcessPipes`` method was added in Symfony 2.4. + +.. 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. +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->setProcessPipes(new NullProcessPipes()); $process->run(); - $process->getOutput() // Will be empty, but this process will never block on output! + $process->getOutput(); // Will be empty, but this process will never block on output! Process Pid -----------