MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / openpt

Function openpt

src/pty.rs:91–108  ·  view source on GitHub ↗
(flags: OpenptFlags)

Source from the content-addressed store, hash-verified

89#[inline]
90#[doc(alias = "posix_openpt")]
91pub 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///

Callers 9

test_termios_flushFunction · 0.50
test_termios_drainFunction · 0.50
test_termios_winsizeFunction · 0.50
test_termios_modesFunction · 0.50
test_termios_speedsFunction · 0.50
pgrp_pseudoterminalFunction · 0.50
openpty_basicFunction · 0.50
openpty_get_peerFunction · 0.50

Calls 1

openFunction · 0.70

Tested by 9

test_termios_flushFunction · 0.40
test_termios_drainFunction · 0.40
test_termios_winsizeFunction · 0.40
test_termios_modesFunction · 0.40
test_termios_speedsFunction · 0.40
pgrp_pseudoterminalFunction · 0.40
openpty_basicFunction · 0.40
openpty_get_peerFunction · 0.40