Skip to content

Instantly share code, notes, and snippets.

@pibi
Created May 11, 2016 14:33
Show Gist options
  • Save pibi/d6c90e23a9224164893cbe6882bc8b5c to your computer and use it in GitHub Desktop.
Save pibi/d6c90e23a9224164893cbe6882bc8b5c to your computer and use it in GitHub Desktop.
Child Process survival test for node
setInterval(function () {
console.log(Date.now());
}, 1000);
const spawn = require('child_process').spawn;
const os = require('os');
//child doesn't exit on windows, for linux we should use stdio:'ignore'
const child = spawn('node', ['interval'], { detached: true, stdio: (os.type() !== 'Windows_NT')? 'ignore' : null});
child.unref();
const spawn = require('child_process').spawn;
const child = spawn('node', ['interval'], { stdio: 'inherit' });
const spawn = require('child_process').spawnSync;
const child = spawn('node', ['interval']);
const spawn = require('child_process').spawnSync;
const child = spawn('node', ['interval'], { stdio: 'inherit' });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment