Skip to content

Commit d57765d

Browse files
committed
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.
2 parents 32f6c11 + 10b956a commit d57765d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/librustuv/tty.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ impl TtyWatcher {
3939
// Related:
4040
// - https://github.com/joyent/libuv/issues/982
4141
// - https://github.com/joyent/libuv/issues/988
42-
if unsafe { uvll::guess_handle(fd) != uvll::UV_TTY as libc::c_int } {
42+
let guess = unsafe { uvll::guess_handle(fd) };
43+
if readable && guess != uvll::UV_TTY as libc::c_int {
4344
return Err(UvError(uvll::EBADF));
4445
}
4546

@@ -100,6 +101,10 @@ impl RtioTTY for TtyWatcher {
100101
n => Err(uv_error_to_io_error(UvError(n)))
101102
}
102103
}
104+
105+
fn isatty(&self) -> bool {
106+
unsafe { uvll::guess_handle(self.fd) == uvll::UV_TTY as libc::c_int }
107+
}
103108
}
104109

105110
impl UvHandle<uvll::uv_tty_t> for TtyWatcher {

src/libstd/io/native/file.rs

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ impl rtio::RtioTTY for FileDesc {
167167
fn get_winsize(&mut self) -> Result<(int, int), IoError> {
168168
Err(super::unimpl())
169169
}
170+
fn isatty(&self) -> bool { false }
170171
}
171172

172173
impl Drop for FileDesc {

src/libstd/rt/rtio.rs

+1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ pub trait RtioTTY {
230230
fn write(&mut self, buf: &[u8]) -> Result<(), IoError>;
231231
fn set_raw(&mut self, raw: bool) -> Result<(), IoError>;
232232
fn get_winsize(&mut self) -> Result<(int, int), IoError>;
233+
fn isatty(&self) -> bool;
233234
}
234235

235236
pub trait PausibleIdleCallback {

0 commit comments

Comments
 (0)