about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-11-19 05:16:24 -0800
committerbors <bors@rust-lang.org>2013-11-19 05:16:24 -0800
commitd57765d8a9d5c1136b914d0d3a073d44882f4ba9 (patch)
treed47ac0e64901ba86e50737b534d021838541d337
parent32f6c11dfab019181b77fe48a876c3ba38b0c72a (diff)
parent10b956a012a93c19d6deb0159a67d25011f622e1 (diff)
downloadrust-d57765d8a9d5c1136b914d0d3a073d44882f4ba9.tar.gz
rust-d57765d8a9d5c1136b914d0d3a073d44882f4ba9.zip
auto merge of #10558 : alexcrichton/rust/faster-stdout, r=pcwalton,pcwalton
There are issues with reading stdin when it is actually attached to a pipe, but
I have run into no problems in writing to stdout/stderr when they are attached
to pipes.
-rw-r--r--src/librustuv/tty.rs7
-rw-r--r--src/libstd/io/native/file.rs1
-rw-r--r--src/libstd/rt/rtio.rs1
3 files changed, 8 insertions, 1 deletions
diff --git a/src/librustuv/tty.rs b/src/librustuv/tty.rs
index c7c09f3480e..1cac5872ed3 100644
--- a/src/librustuv/tty.rs
+++ b/src/librustuv/tty.rs
@@ -39,7 +39,8 @@ impl TtyWatcher {
         // Related:
         // - https://github.com/joyent/libuv/issues/982
         // - https://github.com/joyent/libuv/issues/988
-        if unsafe { uvll::guess_handle(fd) != uvll::UV_TTY as libc::c_int } {
+        let guess = unsafe { uvll::guess_handle(fd) };
+        if readable && guess != uvll::UV_TTY as libc::c_int {
             return Err(UvError(uvll::EBADF));
         }
 
@@ -100,6 +101,10 @@ impl RtioTTY for TtyWatcher {
             n => Err(uv_error_to_io_error(UvError(n)))
         }
     }
+
+    fn isatty(&self) -> bool {
+        unsafe { uvll::guess_handle(self.fd) == uvll::UV_TTY as libc::c_int }
+    }
 }
 
 impl UvHandle<uvll::uv_tty_t> for TtyWatcher {
diff --git a/src/libstd/io/native/file.rs b/src/libstd/io/native/file.rs
index 5e39460ba6a..c157efa7d38 100644
--- a/src/libstd/io/native/file.rs
+++ b/src/libstd/io/native/file.rs
@@ -167,6 +167,7 @@ impl rtio::RtioTTY for FileDesc {
     fn get_winsize(&mut self) -> Result<(int, int), IoError> {
         Err(super::unimpl())
     }
+    fn isatty(&self) -> bool { false }
 }
 
 impl Drop for FileDesc {
diff --git a/src/libstd/rt/rtio.rs b/src/libstd/rt/rtio.rs
index 35fb8baa6ce..775f9d6c3be 100644
--- a/src/libstd/rt/rtio.rs
+++ b/src/libstd/rt/rtio.rs
@@ -230,6 +230,7 @@ pub trait RtioTTY {
     fn write(&mut self, buf: &[u8]) -> Result<(), IoError>;
     fn set_raw(&mut self, raw: bool) -> Result<(), IoError>;
     fn get_winsize(&mut self) -> Result<(int, int), IoError>;
+    fn isatty(&self) -> bool;
 }
 
 pub trait PausibleIdleCallback {