1
0
Fork 0
forked from wry/wry

all: simplify handling of Errno values

This commit is contained in:
Julian Orth 2026-04-02 18:34:12 +02:00
parent 9c605df692
commit 34914eccb0
58 changed files with 443 additions and 464 deletions

View file

@ -1,13 +1,16 @@
use {crate::utils::oserror::OsError, uapi::c};
use {
crate::utils::oserror::{OsError, OsErrorExt},
uapi::c,
};
pub fn set_nonblock(fd: c::c_int) -> Result<(), OsError> {
let fl = uapi::fcntl_getfl(fd)?;
uapi::fcntl_setfl(fd, fl | c::O_NONBLOCK)?;
let fl = uapi::fcntl_getfl(fd).to_os_error()?;
uapi::fcntl_setfl(fd, fl | c::O_NONBLOCK).to_os_error()?;
Ok(())
}
pub fn set_block(fd: c::c_int) -> Result<(), OsError> {
let fl = uapi::fcntl_getfl(fd)?;
uapi::fcntl_setfl(fd, fl & !c::O_NONBLOCK)?;
let fl = uapi::fcntl_getfl(fd).to_os_error()?;
uapi::fcntl_setfl(fd, fl & !c::O_NONBLOCK).to_os_error()?;
Ok(())
}