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.
This commit is contained in:
Alex Crichton 2013-11-18 16:26:03 -08:00
parent 3d569df41d
commit 10b956a012
3 changed files with 8 additions and 1 deletions

View file

@ -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 {