diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-11-18 16:26:03 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-11-18 16:29:41 -0800 |
| commit | 10b956a012a93c19d6deb0159a67d25011f622e1 (patch) | |
| tree | 5dcf823d29b8ac2df0061d9660b28b503fe53bfd /src | |
| parent | 3d569df41de221ce5b0ffd385caaa9fd6d5fb2ff (diff) | |
| download | rust-10b956a012a93c19d6deb0159a67d25011f622e1.tar.gz rust-10b956a012a93c19d6deb0159a67d25011f622e1.zip | |
Allow piped stdout/stderr use uv_tty_t
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustuv/tty.rs | 7 | ||||
| -rw-r--r-- | src/libstd/io/native/file.rs | 1 | ||||
| -rw-r--r-- | src/libstd/rt/rtio.rs | 1 |
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 { |
