<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>yes/no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>3.2.2</td>
</tr>
</tbody>
</table>
<p dir="auto">When executing a command which throws a null error the isSuccessFul() method of Symfony\Component\Process\Process returns true.</p>
<p dir="auto">For example, when executing the following command:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class FailingCronCommand extends ContainerAwareCommand
{

  protected function configure()
  {
    $this-&gt;setName('command:fail');
  }

  protected function execute(InputInterface $input, OutputInterface $output)
  {
    $testNull = null;
    // throw new \Exception('FAIL');
    if ($testNull-&gt;getName() === null) {
      // never gets here because $testNull is null and trying getName() throws an error
    }
  }
}"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">FailingCronCommand</span> <span class="pl-k">extends</span> <span class="pl-v">ContainerAwareCommand</span>
{

  <span class="pl-k">protected</span> <span class="pl-k">function</span> <span class="pl-en">configure</span>()
  {
    <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">setName</span>(<span class="pl-s">'command:fail'</span>);
  }

  <span class="pl-k">protected</span> <span class="pl-k">function</span> <span class="pl-en">execute</span>(<span class="pl-smi"><span class="pl-smi">InputInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>input</span>, <span class="pl-smi"><span class="pl-smi">OutputInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>output</span>)
  {
    <span class="pl-s1"><span class="pl-c1">$</span>testNull</span> = <span class="pl-c1">null</span>;
    <span class="pl-c">// throw new \Exception('FAIL');</span>
    <span class="pl-k">if</span> (<span class="pl-s1"><span class="pl-c1">$</span>testNull</span>-&gt;<span class="pl-en">getName</span>() === <span class="pl-c1">null</span>) {
      <span class="pl-c">// never gets here because $testNull is null and trying getName() throws an error</span>
    }
  }
}</pre></div>
<p dir="auto">using the following code:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/**
 * $console contains the full path to bin/console
 * @var Symfony\Component\Process\Process $process
 */
$process = new Process('php ' .self::$console. ' command:fail');
$process-&gt;run();
$process-&gt;isSuccessful(); // returns true
$process-&gt;getExitCode(); // returns 0 (OK)
$process-&gt;getErrorOutput();
/**
  [Symfony\Component\Debug\Exception\FatalThrowableError]
  Call to a member function getName() on null
**/"><pre class="notranslate"><span class="pl-c">/**</span>
<span class="pl-c"> * $console contains the full path to bin/console</span>
<span class="pl-c"> * @var Symfony\Component\Process\Process $process</span>
<span class="pl-c"> */</span>
<span class="pl-s1"><span class="pl-c1">$</span>process</span> = <span class="pl-k">new</span> <span class="pl-v">Process</span>(<span class="pl-s">'php '</span> .<span class="pl-smi">self</span>::<span class="pl-s1"><span class="pl-c1">$</span>console</span>. <span class="pl-s">' command:fail'</span>);
<span class="pl-s1"><span class="pl-c1">$</span>process</span>-&gt;<span class="pl-en">run</span>();
<span class="pl-s1"><span class="pl-c1">$</span>process</span>-&gt;<span class="pl-en">isSuccessful</span>(); <span class="pl-c">// returns true</span>
<span class="pl-s1"><span class="pl-c1">$</span>process</span>-&gt;<span class="pl-en">getExitCode</span>(); <span class="pl-c">// returns 0 (OK)</span>
<span class="pl-s1"><span class="pl-c1">$</span>process</span>-&gt;<span class="pl-en">getErrorOutput</span>();
<span class="pl-c">/**</span>
<span class="pl-c">  [Symfony\Component\Debug\Exception\FatalThrowableError]</span>
<span class="pl-c">  Call to a member function getName() on null</span>
<span class="pl-c">**/</span></pre></div>
<p dir="auto">When throwing a custom exception in <code class="notranslate">command:fail</code> the process I get the following output:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$process-&gt;isSuccessful(); // returns false
$process-&gt;getExitCode(); // returns 1 (general error)"><pre class="notranslate"><span class="pl-s1"><span class="pl-c1">$</span>process</span>-&gt;<span class="pl-en">isSuccessful</span>(); <span class="pl-c">// returns false</span>
<span class="pl-s1"><span class="pl-c1">$</span>process</span>-&gt;<span class="pl-en">getExitCode</span>(); <span class="pl-c">// returns 1 (general error)</span></pre></div>
<p dir="auto">I also tried setting the "suppress_errors" option to false, but that did not seem to make any difference.</p>
<p dir="auto">Given an new symfony 3.2 project, with this simple Command :</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?php
namespace AppBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class DemoCommand extends Command
{
    protected function configure()
    {
      $this-&gt;setName('app:demo');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
      $input-&gt;checkYourself();
    }
}"><pre class="notranslate"><span class="pl-ent">&lt;?php</span>
<span class="pl-k">namespace</span> <span class="pl-v">AppBundle</span>\<span class="pl-v">Command</span>;

<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Command</span>\<span class="pl-v">Command</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Input</span>\<span class="pl-v">InputInterface</span>;
<span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Output</span>\<span class="pl-v">OutputInterface</span>;

<span class="pl-k">class</span> <span class="pl-v">DemoCommand</span> <span class="pl-k">extends</span> <span class="pl-v">Command</span>
{
    <span class="pl-k">protected</span> <span class="pl-k">function</span> <span class="pl-en">configure</span>()
    {
      <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">setName</span>(<span class="pl-s">'app:demo'</span>);
    }

    <span class="pl-k">protected</span> <span class="pl-k">function</span> <span class="pl-en">execute</span>(<span class="pl-smi"><span class="pl-smi">InputInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>input</span>, <span class="pl-smi"><span class="pl-smi">OutputInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>output</span>)
    {
      <span class="pl-s1"><span class="pl-c1">$</span>input</span>-&gt;<span class="pl-en">checkYourself</span>();
    }
}</pre></div>
<p dir="auto">Running under PHP 5.6.24 :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="bin/console app:demo
[output an UndefinedMethodException]
echo $?
255"><pre class="notranslate"><code class="notranslate">bin/console app:demo
[output an UndefinedMethodException]
echo $?
255
</code></pre></div>
<p dir="auto">Running under PHP 7.0.8 :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="bin/console app:demo
[output an UndefinedMethodException]
echo $?
0"><pre class="notranslate"><code class="notranslate">bin/console app:demo
[output an UndefinedMethodException]
echo $?
0
</code></pre></div>