title: 2nd node child process fails to run on linux
body: <p>So I needed a way to restart my bot within itself and came up with this eventually, however when testing on a Raspberry Pi using ssh it exits after the first child process ends, whereas on Windows it continuously repeats this cycle</p>
  <p>Run using node run.js</p>
  <p>run.js</p>
  <pre class="lang-js prettyprint-override"><code>const { spawn } = require('child_process');
  
  var bot;
  
  function startBot() {
    bot = spawn('node', [&quot;bot.js&quot;]);
  
    bot.stdout.on('data', data =&gt; console.log(data.toString()));
    bot.stderr.on('data', data =&gt; console.error(data.toString()));
  
    bot.on('close', code =&gt; {
      if (code === 1234) startBot();
    });
  }
  
  startBot();
  </code></pre>
  <p>bot.js</p>
  <pre><code>setTimeout(() =&gt; {
    console.log(&quot;child process exiting...&quot;);
    process.exit(1234);
  }, 5000)
  </code></pre>
  <p>Output on Windows:</p>
  <pre><code>PS C:\Users\[removed]\Desktop\despacito\despacito-spider\test&gt; node run.js
  child process exiting...
  
  
  child process exiting...
  
  child process exiting...
  
  child process exiting...
  
  child process exiting...
  </code></pre>
  <p>Output on the Raspi</p>
  <pre><code>pi@raspberrypi:~/Desktop/despacito-spider/test $ node run.js
  child process exiting...
  
  pi@raspberrypi:~/Desktop/despacito-spider/test $
  </code></pre>