uv_guess_handle is currently squelching both fifo and all
sockets on to the UV_NAMED_PIPE type. Rather than treating
all sockets as UV_NAMED_PIPE, use getsockopt() and
getsockaddr() to determine if the socket is an AF_UNIX
stream (in which case return UV_NAMED_PIPE), or an AF_INET
stream (in which case return UV_TCP), or an AF_INET datagram
socket (in which case return UV_UDP).
Additionally, currently all other file descriptor types are
squelched to the UV_FILE type. Instead, only file descriptors
that are marked as regular files are treated as UV_FILE. All
other types (such as directories, character and block devices)
are now treated as UV_UNKNOWN_HANDLE.
kqueue(2) on osx doesn't work (emits EINVAL error) with specific fds
(i.e. /dev/tty, /dev/null, etc). When given such descriptors - start
select(2) watcher thread that will emit io events.
This reverts commit 31f9fbce63.
The reverted commit depends on commit 5da380a ("use select() for specific fds
on OS X") which polls /dev/tty file descriptors in a separate thread to work
around deficiencies in the kqueue API on OS X.
Unfortunately, 5da380a has a bug that effectively makes the select() thread
busy-loop. Revert this commit for now.
Reopen the file descriptor when it refers to a tty. This lets us put the tty in
non-blocking mode without affecting other processes that share it with us.
Fixes#601.
Drain, don't flush the tty when switching from cooked to raw mode. Prevents
buffered keystrokes from getting lost. Switching back to cooked mode still
flushes.
Fixesjoyent/node#2744.