fn flock_with_timeout(fd: RawFd, timeout_sec: u64) -> bool {
    let start = Instant::now();
    while start.elapsed().as_secs() < timeout_sec {
        let lock = nix::fcntl::flock(fd, nix::fcntl::FlockArg::LockExclusiveNonblock);
        if !lock.is_err() {
            return true;
        }
        thread::sleep(Duration::from_millis(10));
    }
    false
}
/// flock a file descriptor of the given type within timeout_sec.
/// Return True if successful.
flock a file descriptor of the given type within timeout_sec.
Return True if successful.
flock a file descriptor of the given type within timeout_sec . Return True if successful .
fn flock_with_timeout(fd: RawFd, timeout_sec: u64) -> bool {
    let start = Instant::now();
    while start.elapsed().as_secs() < timeout_sec {
        let lock = nix::fcntl::flock(fd, nix::fcntl::FlockArg::LockExclusiveNonblock);
        if !lock.is_err() {
            return true;
        }
        thread::sleep(Duration::from_millis(10));
    }
    false
}
fn flock_with_timeout ( fd : RawFd , timeout_sec : u64 ) -> bool { let start = Instant :: now ( ) ; while start . elapsed ( ) . as_secs ( ) < timeout_sec { let lock = nix :: fcntl :: flock ( fd , nix :: fcntl :: FlockArg :: LockExclusiveNonblock ) ; if ! lock . is_err ( ) { return true ; } thread :: sleep ( Duration :: from_millis ( 10 ) ) ; } false }
flock a file descriptor of the given type within timeout_sec.
flock a file descriptor of the given type within timeout_sec .
fd
RawFd
timeout_sec
u64
fd
RawFd
timeout_sec
u64