Skip to content

Instantly share code, notes, and snippets.

@morganrallen
Last active December 28, 2015 17:59
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 morganrallen/7539701 to your computer and use it in GitHub Desktop.
Save morganrallen/7539701 to your computer and use it in GitHub Desktop.
Demonstrates possible bug in child_process

Demonstrates possible bug in child_process

running node main.js will result in process.stdin.setRawMode being undefined and tty.setRawMode barfing 'Error: can't set raw mode on non-tty'

running node child-using-stdin.js will give the function as expected and give deprecation message rather than barf.

console.log(process.stdin.setRawMode);
require("tty").setRawMode(true);
var spawn = require("child_process").spawn;
var cp = spawn("node", ["child-using-stdin.js"])
process.stdin.pipe(cp.stdin);
cp.stdout.pipe(process.stdout);
cp.stderr.pipe(process.stderr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment