pub fn chdir() -> Result<c_int, i32>
Expand description
Change dir to /
see chdir(2)
Upon successful completion, 0 shall be returned. Otherwise, -1 shall be returned, the current working directory shall remain unchanged, and errno shall be set to indicate the error.
Example:
use fork::chdir;
use std::env;
match chdir() {
Ok(_) => {
let path = env::current_dir().expect("failed current_dir");
assert_eq!(Some("/"), path.to_str());
}
_ => panic!(),
}
§Errors
returns -1
if error
§Panics
Panics if CString::new
fails