Created
June 12, 2012 22:17
-
-
Save TooTallNate/2920470 to your computer and use it in GitHub Desktop.
Attempting to create a `tty.ReadStream` instance from "/dev/tty"
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 assert = require('assert') | |
var fs = require('fs') | |
var tty = require('tty') | |
var ttyFd = fs.openSync('/dev/tty', 'r') | |
assert(tty.isatty(ttyFd)) | |
var stream = new tty.ReadStream(ttyFd) | |
stream.on('error', function (err) { | |
console.error('caught "error" event:', err) | |
}) | |
stream.on('data', function (b) { | |
console.error('caught "data" event (%d bytes):', b.length, b) | |
}) | |
stream.resume() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment