Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Attempting to create a `tty.ReadStream` instance from "/dev/tty"
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
You can’t perform that action at this time.