public
Created

Close child's stdin

  • Download Gist
child.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12
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);
parent.js
JavaScript
1 2 3 4 5 6
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);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.