Skip to content

Commit

Permalink
add support of the unikernel RustyHermit
Browse files Browse the repository at this point in the history
- use the crate hermit-abi as interface to the kernel
  • Loading branch information
stlankes committed Jan 4, 2020
1 parent 0e6ef04 commit b056ef9
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 b056ef9

Please sign in to comment.