diff options
| author | Ralf Jung <post@ralfj.de> | 2022-10-21 10:18:54 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-10-21 10:18:54 +0200 |
| commit | 9b57a2f55a76fa1e3d000932e0a708adb587990c (patch) | |
| tree | 53c592b83ed6929eb66beb179586d09409fc3088 /library/std/src/sys/unix/io.rs | |
| parent | 53e357748675b387b6d25fe563b960cb7a7a0aea (diff) | |
| parent | b1ab3b738ac718da74cd4aa0bb7f362d0adbdf84 (diff) | |
| download | rust-9b57a2f55a76fa1e3d000932e0a708adb587990c.tar.gz rust-9b57a2f55a76fa1e3d000932e0a708adb587990c.zip | |
merge rustc history
Diffstat (limited to 'library/std/src/sys/unix/io.rs')
| -rw-r--r-- | library/std/src/sys/unix/io.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/io.rs b/library/std/src/sys/unix/io.rs index deb5ee76bd0..29c340dd349 100644 --- a/library/std/src/sys/unix/io.rs +++ b/library/std/src/sys/unix/io.rs @@ -1,4 +1,5 @@ use crate::marker::PhantomData; +use crate::os::fd::{AsFd, AsRawFd}; use crate::slice; use libc::{c_void, iovec}; @@ -74,3 +75,8 @@ impl<'a> IoSliceMut<'a> { unsafe { slice::from_raw_parts_mut(self.vec.iov_base as *mut u8, self.vec.iov_len) } } } + +pub fn is_terminal(fd: &impl AsFd) -> bool { + let fd = fd.as_fd(); + unsafe { libc::isatty(fd.as_raw_fd()) != 0 } +} |
