/rust/registry/src/index.crates.io-6f17d22bba15001f/rustix-1.0.7/src/process/ioctl.rs
Line | Count | Source (jump to first uncovered line) |
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( |
26 | | windows, |
27 | | target_os = "aix", |
28 | | target_os = "horizon", |
29 | | target_os = "redox", |
30 | | target_os = "wasi" |
31 | | )))] |
32 | | #[inline] |
33 | | #[doc(alias = "TIOCSCTTY")] |
34 | 0 | pub fn ioctl_tiocsctty<Fd: AsFd>(fd: Fd) -> io::Result<()> { |
35 | 0 | unsafe { ioctl::ioctl(fd, Tiocsctty) } |
36 | 0 | } |
37 | | |
38 | | #[cfg(not(any( |
39 | | windows, |
40 | | target_os = "aix", |
41 | | target_os = "horizon", |
42 | | target_os = "redox", |
43 | | target_os = "wasi" |
44 | | )))] |
45 | | struct Tiocsctty; |
46 | | |
47 | | #[cfg(not(any( |
48 | | windows, |
49 | | target_os = "aix", |
50 | | target_os = "horizon", |
51 | | target_os = "redox", |
52 | | target_os = "wasi" |
53 | | )))] |
54 | | unsafe impl ioctl::Ioctl for Tiocsctty { |
55 | | type Output = (); |
56 | | |
57 | | const IS_MUTATING: bool = false; |
58 | | |
59 | 0 | fn opcode(&self) -> ioctl::Opcode { |
60 | 0 | c::TIOCSCTTY as ioctl::Opcode |
61 | 0 | } |
62 | | |
63 | 0 | fn as_ptr(&mut self) -> *mut c::c_void { |
64 | 0 | crate::utils::as_ptr(&0_u32) as *mut c::c_void |
65 | 0 | } |
66 | | |
67 | 0 | unsafe fn output_from_ptr( |
68 | 0 | _: ioctl::IoctlOutput, |
69 | 0 | _: *mut c::c_void, |
70 | 0 | ) -> io::Result<Self::Output> { |
71 | 0 | Ok(()) |
72 | 0 | } |
73 | | } |