Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piscisaureus/2484626 to your computer and use it in GitHub Desktop.
Save piscisaureus/2484626 to your computer and use it in GitHub Desktop.
var spawn = require('child_process').spawn;
if (process.argv[2] !== 'child') {
/* Master process. */
var cp = spawn(process.execPath,
[process.argv[1], 'child'],
{ customFds: [ -1, -1, 2 ] });
cp.stdout.pause();
} else {
var r, buffer;
buffer = new Buffer(1024);
buffer.fill(42);
do {
r = process.stdout.write(buffer);
console.error("Child: process.stdout.write returned", r);
} while (r);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment