Created
January 26, 2012 15:34
-
-
Save bmeck/1683299 to your computer and use it in GitHub Desktop.
run `echo '1+1' | node parent.js`
This file contains 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 stdin = process.stdin; | |
stdin.resume(); | |
stdin.on('data', function (data) { | |
console.log('GOT STDIN FROM PARENT', data + '') | |
}) | |
// | |
// Keep it alive | |
// | |
setInterval(function() {}, 10000) |
This file contains 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 code = ''; | |
process.stdin.resume(); | |
process.stdin.on('data', function (data) {code += data}) | |
process.stdin.on('end', function () { | |
console.error('WRITING DATA') | |
var child = spawn('node',['child.js']); | |
child.stdout.on('data', function (data) { | |
console.log('CHILD.STDOUT', data + '') | |
}) | |
child.stderr.on('data', function (data) { | |
console.log('CHILD.STDERR', data + '') | |
}) | |
child.stdin.write(code) | |
}) | |
//Just keep this alive... | |
setInterval(function () {}, 10000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment