report end-of-stream on zero-length read

The underlying read system call returns zero to indicate that
end-of-stream was reached.  InputStream.read should return -1 on
end-of-stream.
added useDrain flag to Pty

The PTY's output stream when flushed, makes a call to tcdrain.  This
call is supposed to wait until all output written to the terminal has
been transmitted to the terminal.  On some systems, tcdrain can hang
unpredictably.  Setting the useDrain flag to true on the PTY now allows
the tcdrain call to be skipped.  This allows flush to be passed down
the Writer/OutputStream chain to flush internal buffers, but does not
ensure that the output is actually transmitted to the terminal.