Skip to content

Commit

Permalink
Merge pull request #41 from hermitcore/master
Browse files Browse the repository at this point in the history
add support of the unikernel RustyHermit
  • Loading branch information
softprops authored Jan 4, 2020
2 parents 0e6ef04 + b056ef9 commit 84767e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ travis-ci = { repository = "softprops/atty" }
[target.'cfg(unix)'.dependencies]
libc = { version = "0.2", default-features = false }

[target.'cfg(target_os = "hermit")'.dependencies]
hermit-abi = "0.1.6"

[target.'cfg(windows)'.dependencies.winapi]
version = "0.3"
features = ["consoleapi", "processenv", "minwinbase", "minwindef", "winbase"]
Expand Down
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ pub fn is(stream: Stream) -> bool {
unsafe { libc::isatty(fd) != 0 }
}

/// returns true if this is a tty
#[cfg(target_os = "hermit")]
pub fn is(stream: Stream) -> bool {
extern crate hermit_abi;

let fd = match stream {
Stream::Stdout => hermit_abi::STDOUT_FILENO,
Stream::Stderr => hermit_abi::STDERR_FILENO,
Stream::Stdin => hermit_abi::STDIN_FILENO,
};
hermit_abi::isatty(fd)
}

/// returns true if this is a tty
#[cfg(windows)]
pub fn is(stream: Stream) -> bool {
Expand Down

0 comments on commit 84767e0

Please sign in to comment.