• Home
  • Raw
  • Download

Lines Matching +full:use +full:- +full:pty

1 //! Create master and slave virtual pseudo-terminals (PTYs)
3 pub use libc::pid_t as SessionId;
4 pub use libc::winsize as Winsize;
6 use std::ffi::CStr;
7 use std::io;
9 use std::mem;
10 use std::os::unix::prelude::*;
12 use crate::errno::Errno;
14 use crate::sys::termios::Termios;
16 use crate::unistd::Pid;
17 use crate::{fcntl, unistd, Result};
19 /// Representation of a master/slave pty pair
24 /// The master port in a virtual pty pair
26 /// The slave port in a virtual pty pair
48 /// Representation of the Master device in a master/slave pty pair
50 /// While this datatype is a thin wrapper around `OwnedFd`, it enforces that the available PTY
56 fn as_raw_fd(&self) -> RawFd { in as_raw_fd()
62 fn as_fd(&self) -> BorrowedFd<'_> { in as_fd()
68 fn into_raw_fd(self) -> RawFd { in into_raw_fd()
75 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { in read()
81 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { in write()
84 fn flush(&mut self) -> io::Result<()> { in flush()
90 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { in read()
96 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { in write()
99 fn flush(&mut self) -> io::Result<()> { in flush()
110 pub fn grantpt(fd: &PtyMaster) -> Result<()> { in grantpt()
125 /// A common use case with this function is to open both a master and slave PTY pair. This can be
129 /// use std::path::Path;
130 /// use nix::fcntl::{OFlag, open};
131 /// use nix::pty::{grantpt, posix_openpt, ptsname, unlockpt};
132 /// use nix::sys::stat::Mode;
135 /// # fn run() -> nix::Result<()> {
136 /// // Open a new PTY master
152 pub fn posix_openpt(flags: fcntl::OFlag) -> Result<PtyMaster> { in posix_openpt()
163 /// [`ptsname(3)`](https://man7.org/linux/man-pages/man3/ptsname.3.html))
168 /// This value is useful for opening the slave pty once the master has already been opened with
177 /// For a threadsafe and non-`unsafe` alternative on Linux, see `ptsname_r()`.
179 pub unsafe fn ptsname(fd: &PtyMaster) -> Result<String> { in ptsname()
190 /// [`ptsname(3)`](https://man7.org/linux/man-pages/man3/ptsname.3.html))
194 /// POSIX standard and is instead a Linux-specific extension.
200 pub fn ptsname_r(fd: &PtyMaster) -> Result<String> { in ptsname_r()
222 pub fn unlockpt(fd: &PtyMaster) -> Result<()> { in unlockpt()
232 /// (see [`openpty`](https://man7.org/linux/man-pages/man3/openpty.3.html)).
247 ) -> Result<OpenptyResult> { in openpty()
248 use std::ptr; in openpty()
319 /// In a multithreaded program, only [async-signal-safe] functions like `pause`
321 /// that memory allocation may **not** be async-signal-safe and thus must be
327 /// [async-signal-safe]: https://man7.org/linux/man-pages/man7/signal-safety.7.html
332 /// * [Linux](https://man7.org/linux/man-pages/man3/forkpty.3.html)
337 ) -> Result<ForkptyResult> {
338 use std::ptr;