summaryrefslogtreecommitdiff
path: root/src/pty.rs
diff options
context:
space:
mode:
authorVincent Dagonneau <vincentdagonneau@gmail.com>2020-03-19 11:40:53 +0100
committerAlan Somers <asomers@gmail.com>2021-12-20 18:47:16 -0700
commit5f5b7d4d7a76575673b57e685c13ba2c52c4183e (patch)
tree75b45fc8b1b70750783e89069bc4d90810c500fe /src/pty.rs
parentd1c6fed481638405b0a87e5b7eecf82ce89b2268 (diff)
downloadnix-5f5b7d4d7a76575673b57e685c13ba2c52c4183e.zip
feature-gate most Nix functions
Using features reduces build time and size for consumer crates. By default all features are enabled.
Diffstat (limited to 'src/pty.rs')
-rw-r--r--src/pty.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/pty.rs b/src/pty.rs
index facc9aaf..a104a69c 100644
--- a/src/pty.rs
+++ b/src/pty.rs
@@ -9,8 +9,9 @@ use std::mem;
use std::os::unix::prelude::*;
use crate::sys::termios::Termios;
-use crate::unistd::{self, ForkResult, Pid};
-use crate::{Result, fcntl};
+#[cfg(feature = "process")]
+use crate::unistd::{ForkResult, Pid};
+use crate::{Result, fcntl, unistd};
use crate::errno::Errno;
/// Representation of a master/slave pty pair
@@ -25,6 +26,8 @@ pub struct OpenptyResult {
pub slave: RawFd,
}
+feature! {
+#![feature = "process"]
/// Representation of a master with a forked pty
///
/// This is returned by `forkpty`. Note that this type does *not* implement `Drop`, so the user
@@ -36,6 +39,7 @@ pub struct ForkptyResult {
/// Metadata about forked process
pub fork_result: ForkResult,
}
+}
/// Representation of the Master device in a master/slave pty pair
@@ -188,6 +192,7 @@ pub unsafe fn ptsname(fd: &PtyMaster) -> Result<String> {
/// This value is useful for opening the slave ptty once the master has already been opened with
/// `posix_openpt()`.
#[cfg(any(target_os = "android", target_os = "linux"))]
+#[cfg_attr(docsrs, doc(cfg(all())))]
#[inline]
pub fn ptsname_r(fd: &PtyMaster) -> Result<String> {
let mut name_buf = Vec::<libc::c_char>::with_capacity(64);
@@ -294,6 +299,8 @@ pub fn openpty<'a, 'b, T: Into<Option<&'a Winsize>>, U: Into<Option<&'b Termios>
}
}
+feature! {
+#![feature = "process"]
/// Create a new pseudoterminal, returning the master file descriptor and forked pid.
/// in `ForkptyResult`
/// (see [`forkpty`](https://man7.org/linux/man-pages/man3/forkpty.3.html)).
@@ -346,3 +353,4 @@ pub unsafe fn forkpty<'a, 'b, T: Into<Option<&'a Winsize>>, U: Into<Option<&'b T
fork_result,
})
}
+}