Coverage Report

Created: 2025-11-24 06:55

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-1.1.2/src/process/pidfd.rs
Line
Count
Source
1
use crate::fd::OwnedFd;
2
use crate::process::{Pid, Signal};
3
use crate::{backend, ffi, io};
4
use backend::fd::AsFd;
5
6
bitflags::bitflags! {
7
    /// `PIDFD_*` flags for use with [`pidfd_open`].
8
    ///
9
    /// [`pidfd_open`]: crate::process::pidfd_open
10
    #[repr(transparent)]
11
    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
12
    pub struct PidfdFlags: ffi::c_uint {
13
        /// `PIDFD_NONBLOCK`
14
        const NONBLOCK = backend::c::PIDFD_NONBLOCK;
15
16
        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
17
        const _ = !0;
18
    }
19
}
20
21
/// `syscall(SYS_pidfd_open, pid, flags)`—Creates a file descriptor for a
22
/// process.
23
///
24
/// # References
25
///  - [Linux]
26
///
27
/// [Linux]: https://man7.org/linux/man-pages/man2/pidfd_open.2.html
28
#[inline]
29
0
pub fn pidfd_open(pid: Pid, flags: PidfdFlags) -> io::Result<OwnedFd> {
30
0
    backend::process::syscalls::pidfd_open(pid, flags)
31
0
}
32
33
/// `syscall(SYS_pidfd_send_signal, pidfd, sig, NULL, 0)`—Send a signal to a
34
/// process specified by a file descriptor.
35
///
36
/// # References
37
///  - [Linux]
38
///
39
/// [Linux]: https://man7.org/linux/man-pages/man2/pidfd_send_signal.2.html
40
#[inline]
41
0
pub fn pidfd_send_signal<Fd: AsFd>(pidfd: Fd, sig: Signal) -> io::Result<()> {
42
0
    backend::process::syscalls::pidfd_send_signal(pidfd.as_fd(), sig)
43
0
}