Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var spawn = require('child_process').spawn;
var depth = process.argv[2];
if (!depth) {
var p = spawn('node', [ process.argv[1], '1' ], { stdio: 'inherit' });
setTimeout(() => {
console.log(process.pid, 'Killing child', p.pid);
p.kill();
}, 500);
} else if (depth === '1') {
console.log(process.pid, 'Hello from child');
spawn('node', [ process.argv[1], '2' ], { stdio: 'inherit' });
} else if (depth === '2') {
console.log(process.pid, 'Hello from grand child');
setTimeout(() => { console.log(process.pid, '!!! Want not to be printed') }, 2 * 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.