Created
April 26, 2016 01:52
-
-
Save motemen/07e1feb114d7fe7cd8e4fab7052db082 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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