| 89 | #[inline] |
| 90 | #[doc(alias = "posix_openpt")] |
| 91 | pub fn openpt(flags: OpenptFlags) -> io::Result<OwnedFd> { |
| 92 | // On Linux, open the device ourselves so that we can support `CLOEXEC`. |
| 93 | #[cfg(linux_kernel)] |
| 94 | { |
| 95 | use crate::fs::{open, Mode}; |
| 96 | match open(cstr!("/dev/ptmx"), flags.into(), Mode::empty()) { |
| 97 | // Match libc `openat` behavior with `ENOSPC`. |
| 98 | Err(io::Errno::NOSPC) => Err(io::Errno::AGAIN), |
| 99 | otherwise => otherwise, |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | // On all other platforms, use `openpt`. |
| 104 | #[cfg(not(linux_kernel))] |
| 105 | { |
| 106 | backend::pty::syscalls::openpt(flags) |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | /// `ptsname(fd)`—Return the name of a pseudoterminal. |
| 111 | /// |