1use crate::fd::OwnedFd;
2use crate::process::Pid;
3use crate::{backend, io};
4
5bitflags::bitflags! {
6 /// `PIDFD_*` flags for use with [`pidfd_open`].
7 ///
8 /// [`pidfd_open`]: crate::process::pidfd_open
9 pub struct PidfdFlags: backend::c::c_uint {
10 /// `PIDFD_NONBLOCK`.
11 const NONBLOCK = backend::c::PIDFD_NONBLOCK;
12 }
13}
14
15/// `syscall(SYS_pidfd_open, pid, flags)`—Creates a file descriptor for
16/// a process.
17///
18/// # References
19/// - [Linux]
20///
21/// [Linux]: https://man7.org/linux/man-pages/man2/pidfd_open.2.html
22#[inline]
23pub fn pidfd_open(pid: Pid, flags: PidfdFlags) -> io::Result<OwnedFd> {
24 backend::process::syscalls::pidfd_open(pid, flags)
25}
26