1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! linux_raw syscalls for PIDs
//!
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
#![allow(unsafe_code, clippy::undocumented_unsafe_blocks)]

use crate::backend::conv::ret_usize_infallible;
use crate::pid::{Pid, RawPid};

#[inline]
pub(crate) fn getpid() -> Pid {
    unsafe {
        let pid = ret_usize_infallible(syscall_readonly!(__NR_getpid)) as RawPid;
        Pid::from_raw_unchecked(pid)
    }
}