[][src]Function fcntl::unlock_file

pub fn unlock_file<'a, RF>(
    fd: &'a RF,
    flock: Option<flock>
) -> Result<bool, FcntlError> where
    RF: AsRawFd

Releases the lock on the given file (using FcntlCmd::SetLock). If flock is None all parameters of the flock structure (l_whence, l_start, l_len, l_pid) will be set to 0. flock.l_type will be set to libc::F_UNLCK regardless of its original value.

use std::fs::OpenOptions;
use fcntl::unlock_file;

let file = OpenOptions::new().read(true).open(file_name).unwrap();
match unlock_file(&file, None) {
    Ok(true) => println!("Lock successfully released"),
    Ok(false) => println!("Falied to release lock"),
    Err(err) => println!("Error: {:?}", err),
}