Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow piped stdout/stderr use uv_tty_t #10558

Merged
merged 1 commit into from
Nov 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/librustuv/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/libstd/io/native/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/libstd/rt/rtio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down