• 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;
8 use std::mem;
9 use std::os::unix::prelude::*;
11 use crate::errno::Errno;
12 use crate::sys::termios::Termios;
14 use crate::unistd::{ForkResult, Pid};
15 use crate::{fcntl, unistd, Result};
17 /// Representation of a master/slave pty pair
23 /// The master port in a virtual pty pair
25 /// The slave port in a virtual pty pair
31 /// Representation of a master with a forked pty
37 /// The master port in a virtual pty pair
44 /// Representation of the Master device in a master/slave pty pair
46 /// While this datatype is a thin wrapper around `RawFd`, it enforces that the available PTY
48 /// so that when it's consumed or goes out of scope, it's automatically cleaned-up.
53 fn as_raw_fd(&self) -> RawFd { in as_raw_fd()
59 fn into_raw_fd(self) -> RawFd { in into_raw_fd()
72 // invalid file descriptor. That frequently indicates a double-close in drop()
83 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { in read()
89 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { in write()
92 fn flush(&mut self) -> io::Result<()> { in flush()
98 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { in read()
104 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { in write()
107 fn flush(&mut self) -> io::Result<()> { in flush()
118 pub fn grantpt(fd: &PtyMaster) -> Result<()> { in grantpt()
133 /// A common use case with this function is to open both a master and slave PTY pair. This can be
137 /// use std::path::Path;
138 /// use nix::fcntl::{OFlag, open};
139 /// use nix::pty::{grantpt, posix_openpt, ptsname, unlockpt};
140 /// use nix::sys::stat::Mode;
143 /// # fn run() -> nix::Result<()> {
144 /// // Open a new PTY master
160 pub fn posix_openpt(flags: fcntl::OFlag) -> Result<PtyMaster> { in posix_openpt()
171 /// [`ptsname(3)`](https://man7.org/linux/man-pages/man3/ptsname.3.html))
176 /// This value is useful for opening the slave pty once the master has already been opened with
185 /// For a threadsafe and non-`unsafe` alternative on Linux, see `ptsname_r()`.
187 pub unsafe fn ptsname(fd: &PtyMaster) -> Result<String> { in ptsname()
198 /// [`ptsname(3)`](https://man7.org/linux/man-pages/man3/ptsname.3.html))
202 /// POSIX standard and is instead a Linux-specific extension.
209 pub fn ptsname_r(fd: &PtyMaster) -> Result<String> { in ptsname_r()
231 pub fn unlockpt(fd: &PtyMaster) -> Result<()> { in unlockpt()
241 /// (see [`openpty`](https://man7.org/linux/man-pages/man3/openpty.3.html)).
255 ) -> Result<OpenptyResult> { in openpty()
256 use std::ptr; in openpty()
321 /// (see [`forkpty`](https://man7.org/linux/man-pages/man3/forkpty.3.html)).
329 /// In a multithreaded program, only [async-signal-safe] functions like `pause`
331 /// that memory allocation may **not** be async-signal-safe and thus must be
337 /// [async-signal-safe]: https://man7.org/linux/man-pages/man7/signal-safety.7.html
341 ) -> Result<ForkptyResult> {
342 use std::ptr;