Skip to content

Instantly share code, notes, and snippets.

@shirish87
Last active March 10, 2016 21:22
Show Gist options
  • Save shirish87/9f66f1a5d730e386717d to your computer and use it in GitHub Desktop.
Save shirish87/9f66f1a5d730e386717d to your computer and use it in GitHub Desktop.
var spawn = require('child_process').spawn;
var child = spawn('node', ['child.js', 'arg2'], {
cwd: process.cwd(),
env: process.env,
detached: false,
stdio: [ 'ignore', 'ignore', 'ignore', 'ipc' ]
})
.on('message', function (m) {
// console.log('message', m);
// child.disconnect();
// child.unref();
})
.on('exit', console.error);
setInterval(function () {
console.log('args', process.argv);
process.send && process.send({ message: 'what' });
}, 1000);
var spawn = require('child_process').spawn;
var child = spawn('node', ['child.js', 'arg1'], {
cwd: process.cwd(),
env: process.env,
detached: true,
stdio: [ 'ignore', 'ignore', 'ignore', 'ipc' ]
})
.on('message', function (m) {
console.log('message', m);
// child.disconnect();
// child.unref();
})
.on('exit', console.error)
setInterval(function () { }, 2000);
var child = spawn('cmd.exe', [ '/C', 'start', '/B', process.execPath, 'child.js', 'arg1' ], {
cwd: process.cwd(),
env: process.env,
detached: false,
windowsVerbatimArguments: true,
stdio: ['ignore', 'ignore', 'ignore']
})
.on('exit', console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment