/rust/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-1.1.5/src/process/ioctl.rs
Line | Count | Source |
1 | | //! Process-oriented `ioctl`s. |
2 | | //! |
3 | | //! # Safety |
4 | | //! |
5 | | //! This module invokes `ioctl`s. |
6 | | |
7 | | #![allow(unsafe_code)] |
8 | | |
9 | | use crate::{backend, io, ioctl}; |
10 | | use backend::c; |
11 | | use backend::fd::AsFd; |
12 | | |
13 | | /// `ioctl(fd, TIOCSCTTY, 0)`—Sets the controlling terminal for the process. |
14 | | /// |
15 | | /// # References |
16 | | /// - [Linux] |
17 | | /// - [FreeBSD] |
18 | | /// - [NetBSD] |
19 | | /// - [OpenBSD] |
20 | | /// |
21 | | /// [Linux]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html |
22 | | /// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=tty&sektion=4 |
23 | | /// [NetBSD]: https://man.netbsd.org/tty.4 |
24 | | /// [OpenBSD]: https://man.openbsd.org/tty.4 |
25 | | #[cfg(not(any(windows, target_os = "aix", target_os = "redox", target_os = "wasi")))] |
26 | | #[inline] |
27 | | #[doc(alias = "TIOCSCTTY")] |
28 | 0 | pub fn ioctl_tiocsctty<Fd: AsFd>(fd: Fd) -> io::Result<()> { |
29 | 0 | unsafe { ioctl::ioctl(fd, Tiocsctty) } |
30 | 0 | } |
31 | | |
32 | | #[cfg(not(any(windows, target_os = "aix", target_os = "redox", target_os = "wasi")))] |
33 | | struct Tiocsctty; |
34 | | |
35 | | #[cfg(not(any(windows, target_os = "aix", target_os = "redox", target_os = "wasi")))] |
36 | | unsafe impl ioctl::Ioctl for Tiocsctty { |
37 | | type Output = (); |
38 | | |
39 | | const IS_MUTATING: bool = false; |
40 | | |
41 | 0 | fn opcode(&self) -> ioctl::Opcode { |
42 | 0 | c::TIOCSCTTY as ioctl::Opcode |
43 | 0 | } |
44 | | |
45 | 0 | fn as_ptr(&mut self) -> *mut c::c_void { |
46 | 0 | crate::utils::as_ptr(&0_u32) as *mut c::c_void |
47 | 0 | } |
48 | | |
49 | 0 | unsafe fn output_from_ptr( |
50 | 0 | _: ioctl::IoctlOutput, |
51 | 0 | _: *mut c::c_void, |
52 | 0 | ) -> io::Result<Self::Output> { |
53 | 0 | Ok(()) |
54 | 0 | } |
55 | | } |