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:
parent
3d569df41d
commit
10b956a012
3 changed files with 8 additions and 1 deletions
|
@ -39,7 +39,8 @@ impl TtyWatcher {
|
||||||
// Related:
|
// Related:
|
||||||
// - https://github.com/joyent/libuv/issues/982
|
// - https://github.com/joyent/libuv/issues/982
|
||||||
// - https://github.com/joyent/libuv/issues/988
|
// - 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));
|
return Err(UvError(uvll::EBADF));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +101,10 @@ impl RtioTTY for TtyWatcher {
|
||||||
n => Err(uv_error_to_io_error(UvError(n)))
|
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 {
|
impl UvHandle<uvll::uv_tty_t> for TtyWatcher {
|
||||||
|
|
|
@ -167,6 +167,7 @@ impl rtio::RtioTTY for FileDesc {
|
||||||
fn get_winsize(&mut self) -> Result<(int, int), IoError> {
|
fn get_winsize(&mut self) -> Result<(int, int), IoError> {
|
||||||
Err(super::unimpl())
|
Err(super::unimpl())
|
||||||
}
|
}
|
||||||
|
fn isatty(&self) -> bool { false }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for FileDesc {
|
impl Drop for FileDesc {
|
||||||
|
|
|
@ -230,6 +230,7 @@ pub trait RtioTTY {
|
||||||
fn write(&mut self, buf: &[u8]) -> Result<(), IoError>;
|
fn write(&mut self, buf: &[u8]) -> Result<(), IoError>;
|
||||||
fn set_raw(&mut self, raw: bool) -> Result<(), IoError>;
|
fn set_raw(&mut self, raw: bool) -> Result<(), IoError>;
|
||||||
fn get_winsize(&mut self) -> Result<(int, int), IoError>;
|
fn get_winsize(&mut self) -> Result<(int, int), IoError>;
|
||||||
|
fn isatty(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PausibleIdleCallback {
|
pub trait PausibleIdleCallback {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue