We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dad24fb commit 1ac1cb8Copy full SHA for 1ac1cb8
changelog/2747.changed.md
@@ -0,0 +1 @@
1
+`Dir::as_raw_fd` now panics if `libc::dirfd` returns a negative value.
src/dir.rs
@@ -137,7 +137,9 @@ impl std::os::fd::AsFd for Dir {
137
138
impl AsRawFd for Dir {
139
fn as_raw_fd(&self) -> RawFd {
140
- unsafe { libc::dirfd(self.0.as_ptr()) }
+ let fd = unsafe { libc::dirfd(self.0.as_ptr()) };
141
+ assert!(fd >= 0, "dirfd returned error: {}", Errno::last());
142
+ fd
143
}
144
145
0 commit comments