title: NodeJS child process not firing close event when writing to STDIN
body: <p>I am using the following code to spawn a child process that asks the user for input and then it should complete, but the <code>close</code> event is never fired.</p>
  
  <pre><code>const spawn = require('child_process').spawn;
  const p = spawn('script', ['that', 'prompts', 'user', 'for', 'input']);
  
  process.stdin.on('data', (data) =&gt; {
    p.stdin.write(data);
  });
  
  p.on('close', (code) =&gt; {
    console.log(`child process closed with code ${code}`);
  });
  </code></pre>
  
  <p>If I spawn a process that doesn't prompt for user input (like <code>ls´), the</code>close` event fires without any issue. I suspect something about writing directly into the child process's STDIN from the parent is preventing it from terminating correctly but I can't figure out why. Am I missing something obvious here?</p>