Skip to content

Commit b056ef9

Browse files
committed
add support of the unikernel RustyHermit
- use the crate hermit-abi as interface to the kernel
1 parent 0e6ef04 commit b056ef9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ travis-ci = { repository = "softprops/atty" }
1717
[target.'cfg(unix)'.dependencies]
1818
libc = { version = "0.2", default-features = false }
1919

20+
[target.'cfg(target_os = "hermit")'.dependencies]
21+
hermit-abi = "0.1.6"
22+
2023
[target.'cfg(windows)'.dependencies.winapi]
2124
version = "0.3"
2225
features = ["consoleapi", "processenv", "minwinbase", "minwindef", "winbase"]

src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ pub fn is(stream: Stream) -> bool {
4848
unsafe { libc::isatty(fd) != 0 }
4949
}
5050

51+
/// returns true if this is a tty
52+
#[cfg(target_os = "hermit")]
53+
pub fn is(stream: Stream) -> bool {
54+
extern crate hermit_abi;
55+
56+
let fd = match stream {
57+
Stream::Stdout => hermit_abi::STDOUT_FILENO,
58+
Stream::Stderr => hermit_abi::STDERR_FILENO,
59+
Stream::Stdin => hermit_abi::STDIN_FILENO,
60+
};
61+
hermit_abi::isatty(fd)
62+
}
63+
5164
/// returns true if this is a tty
5265
#[cfg(windows)]
5366
pub fn is(stream: Stream) -> bool {

0 commit comments

Comments
 (0)