title: How to keep forked child process alive in node js
body: <p>I want to create a rabbitmq cli running like foreverjs with node. It can spawn child_process and keep it running in the background and can communicate with child_process at any time. The problem I am facing is when main cli program exit the child_process seems to stop running as well, I tried to fork with detached:true and .unref() it doesn't work. How do i run a child process in the background even after the parent caller process exited? </p>
  
  <p>cli.js - parent</p>
  
  <pre><code>const { fork, spawn } = require('child_process');
  const options = {
    stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
    slient:true,
    detached:true
  };
  
  child = fork('./rabbit.js', [], options)
  
  child.on('message', message =&gt; {
    console.log('message from child:', message);
    child.send('Hi');
    // exit parent
    process.exit(0);
  });
  
  child.unref()
  </code></pre>
  
  <p>rabbit.js - child
  if it is up and running, 'i' should keep incrementing</p>
  
  <pre><code>var i=0;
  i++;
  if (process.send) {
    process.send("Hello"+i);
  }
  
  process.on('message', message =&gt; {
    console.log('message from parent:', message);
  });
  </code></pre>