Skip to content

Instantly share code, notes, and snippets.

@mmalecki
Created December 2, 2011 22:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mmalecki/1425072 to your computer and use it in GitHub Desktop.
Close child's stdin
console.log('Hello');
var stdin = process.openStdin();
stdin.on('data', function (d) {
console.log('Oh, I can exit now');
stdin.pause();
});
process.on('exit', function () {
console.log('Oh, I am exitting now');
});
setTimeout(function () {
console.log('real exit');
}, 1000);
var spawn = require('child_process').spawn;
var c = spawn('node', ['child.js']);
c.stdin.destroy();
c.stdout.pipe(process.stdout);
c.stderr.pipe(process.stderr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment