1 | //! linux_raw syscalls for PIDs |
---|---|
2 | //! |
3 | //! # Safety |
4 | //! |
5 | //! See the `rustix::backend` module documentation for details. |
6 | #![allow(unsafe_code, clippy::undocumented_unsafe_blocks)] |
7 | |
8 | use crate::backend::conv::ret_usize_infallible; |
9 | use crate::pid::{Pid, RawPid}; |
10 | |
11 | #[inline] |
12 | pub(crate) fn getpid() -> Pid { |
13 | unsafe { |
14 | let pid: i32 = ret_usize_infallible(raw:syscall_readonly!(__NR_getpid)) as RawPid; |
15 | Pid::from_raw_unchecked(raw:pid) |
16 | } |
17 | } |
18 |