Skip to content

Instantly share code, notes, and snippets.

@alessioalex
Created May 18, 2015 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alessioalex/be4924eab644ad32d033 to your computer and use it in GitHub Desktop.
Save alessioalex/be4924eab644ad32d033 to your computer and use it in GitHub Desktop.
zombie processes nodejs
// http://stackoverflow.com/questions/12871740/how-to-detach-spawned-child-process-in-a-node-js-script
// https://nodejs.org/api/child_process.html#child_process_options_detached
// var fs = require('fs');
// var out = fs.openSync('./out.log', 'a');
// var err = fs.openSync('./out.log', 'a');
var cp = require('child_process');
// var child = cp.spawn('node', ['zombie.js'], { detached: true, stdio: [ 'ignore', out, err ] });
var child = cp.spawn('node', ['zombie.js'], { detached: true, stdio: [ 'ignore' /* stdin */, 'ignore' /* stdout */, 'ignore' /* stderr */ ] });
child.unref();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment