Skip to content
Merged
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
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ impl<Stream: AsFd> IsTerminal for Stream {
fn is_terminal(&self) -> bool {
#[cfg(any(unix, target_os = "wasi"))]
{
unsafe { libc::isatty(self.as_fd().as_raw_fd()) == 1 }
let fd = self.as_fd();
unsafe { libc::isatty(fd.as_raw_fd()) != 0 }
}

#[cfg(target_os = "hermit")]
Expand All @@ -104,8 +105,8 @@ impl<Stream: AsHandle> IsTerminal for Stream {
}

// The Windows implementation here is copied from `handle_is_console` in
// std/src/sys/windows/io.rs in Rust at revision
// d7b0bcb20f2f7d5f3ea3489d56ece630147e98f5.
// library/std/src/sys/pal/windows/io.rs in Rust at revision
// 99128b7e45f8b95d962da2e6ea584767f0c85455.

#[cfg(windows)]
fn handle_is_console(handle: BorrowedHandle<'_>) -> bool {
Expand Down Expand Up @@ -147,8 +148,6 @@ fn handle_is_console(handle: BorrowedHandle<'_>) -> bool {
}

/// Returns true if there is an MSYS tty on the given handle.
///
/// This incoproates d7b0bcb20f2f7d5f3ea3489d56ece630147e98f5
#[cfg(windows)]
unsafe fn msys_tty_on(handle: HANDLE) -> bool {
use std::ffi::c_void;
Expand Down