LCOV - code coverage report
Current view: top level - libs/utils/src - nonblock.rs (source / functions) Coverage Total Hit
Test: 050dd70dd490b28fffe527eae9fb8a1222b5c59c.info Lines: 0.0 % 8 0
Test Date: 2024-06-25 21:28:46 Functions: 0.0 % 1 0

            Line data    Source code
       1              : use nix::fcntl::{fcntl, OFlag, F_GETFL, F_SETFL};
       2              : use std::os::unix::io::RawFd;
       3              : 
       4              : /// Put a file descriptor into non-blocking mode
       5            0 : pub fn set_nonblock(fd: RawFd) -> Result<(), std::io::Error> {
       6            0 :     let bits = fcntl(fd, F_GETFL)?;
       7              : 
       8              :     // If F_GETFL returns some unknown bits, they should be valid
       9              :     // for passing back to F_SETFL, too. If we left them out, the F_SETFL
      10              :     // would effectively clear them, which is not what we want.
      11            0 :     let mut flags = OFlag::from_bits_retain(bits);
      12            0 :     flags |= OFlag::O_NONBLOCK;
      13            0 : 
      14            0 :     fcntl(fd, F_SETFL(flags))?;
      15              : 
      16            0 :     Ok(())
      17            0 : }
        

Generated by: LCOV version 2.1-beta