process-sync 0.2.2

Synchronization primitives for multiprocess environments
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use libc::pid_t;

#[doc(hidden)]
pub fn check_libc_err<T: Default + Ord>(ret: T) -> std::io::Result<T> {
    if ret < T::default() {
        return Err(std::io::Error::last_os_error());
    }
    return Ok(ret);
}

pub fn getpid() -> pid_t {
    check_libc_err(unsafe { libc::getpid() }).expect("getpid() failed")
}