Don't ignore errors of syscalls in std::sys::unix::fd
If any of these syscalls fail, it indicates a programmer error that should not be silently ignored.
This commit is contained in:
parent
4960f2f907
commit
a32244b3d9
1 changed files with 4 additions and 4 deletions
|
@ -65,7 +65,7 @@ impl FileDesc {
|
|||
pub fn set_cloexec(&self) {
|
||||
unsafe {
|
||||
let ret = libc::ioctl(self.fd, libc::FIOCLEX);
|
||||
debug_assert_eq!(ret, 0);
|
||||
assert_eq!(ret, 0);
|
||||
}
|
||||
}
|
||||
#[cfg(any(target_env = "newlib", target_os = "solaris", target_os = "emscripten"))]
|
||||
|
@ -73,21 +73,21 @@ impl FileDesc {
|
|||
unsafe {
|
||||
let previous = libc::fcntl(self.fd, libc::F_GETFD);
|
||||
let ret = libc::fcntl(self.fd, libc::F_SETFD, previous | libc::FD_CLOEXEC);
|
||||
debug_assert_eq!(ret, 0);
|
||||
assert_eq!(ret, 0);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_nonblocking(&self, nonblocking: bool) {
|
||||
unsafe {
|
||||
let previous = libc::fcntl(self.fd, libc::F_GETFL);
|
||||
debug_assert!(previous != -1);
|
||||
assert!(previous != -1);
|
||||
let new = if nonblocking {
|
||||
previous | libc::O_NONBLOCK
|
||||
} else {
|
||||
previous & !libc::O_NONBLOCK
|
||||
};
|
||||
let ret = libc::fcntl(self.fd, libc::F_SETFL, new);
|
||||
debug_assert!(ret != -1);
|
||||
assert!(ret != -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue