title: node child process: will it always terminate by itself?
body: <p>I have code to spawn child process like this:</p>
  
  <pre><code>const spawn = require('child_process').spawn;
  const ls = spawn('ls', ['-lh', '/usr'], {
      detached: true
  });
  
  ls.stdout.on('data', (data) =&gt; {
    console.log(`stdout: ${data}`);
  });
  
  ls.stderr.on('data', (data) =&gt; {
    console.log(`stderr: ${data}`);
  });
  
  ls..on('error', (data) =&gt; {
    console.log(`error: ${data}`);
  });
  
  ls.on('close', (code) =&gt; {
    console.log(`child process exited with code ${code}`);
  });
  </code></pre>
  
  <p>Till now, I can console message from stdout and stderr, and it exited automatically after finish the task.</p>
  
  <p>My question is:</p>
  
  <ol>
  <li><p>in what situation, it will go to 'error' event?</p></li>
  <li><p>is it possible that child process can't terminate? If so, when could that happen?</p></li>
  <li><p>if case 2 happens, how can I kill these child process when my main process already terminated?</p></li>
  </ol>