Skip to main content

getuid

Function getuid 

Source
pub unsafe fn getuid() -> uid_t
Expand description

Get the real user ID of the calling process.

ยงExamples

let uid = unsafe { nc::getuid() };
assert!(uid > 0);
Examples found in repository?
examples/sethostname.rs (line 3)
1fn main() {
2    let name = "rust-machine";
3    let uid = unsafe { nc::getuid() };
4    let ret = unsafe { nc::sethostname(name) };
5    if uid == 0 {
6        assert!(ret.is_ok());
7    } else {
8        assert!(ret.is_err());
9        assert_eq!(ret, Err(nc::EPERM));
10    }
11}