tty: set the handle to blocking mode by Fishrock123 · Pull Request #6816 · nodejs/node
@jasnell So, there are a couple issues with your API proposal.
The biggest is that actually creating TTY streams isn't particularly supported:
In normal circumstances,
process.stdoutwill be the onlytty.WriteStreaminstance ever created (and only whenisatty(1)istrue).
In fact, I've tried to make tty streams before and found it's virtually impossible. You can only make one if the fd is a tty and it is not already in use, which is basically never. I actually don't know of a case when you could ever make one manually without severe hackery.
However, exposing a setBlocking method publicly also causes some concerns:
- The existing problem that
stdiostreams do not have consistent APIs depending on the stream type is yet again amplified (very difficult to fix) - It doesn't work for pipes, but putting this functionality into
net.Socketpublicly is harmful because of TCP connections. - I'm not sure unblocking is ever valuable for this, in any manor that isn't strictly theoretical.
- Same goes for pipes, where blocking only has theoretical niceties.
describes the default behavior of
tty.ReadStream
I doubt that is useful due to the above, or the correct place to put it, since no-one will go looking for the TTY module from console.log() or process.std{in|out|err}.
I will add a note to where the existing note is for file piping though: https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_process_stderr