Skip to content

Commit

Permalink
fix: only close fanotify events with a valid fd
Browse files Browse the repository at this point in the history
  • Loading branch information
tombl committed May 12, 2024
1 parent 99a890a commit 40b54bf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/sys/fanotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ impl FanotifyEvent {

impl Drop for FanotifyEvent {
fn drop(&mut self) {
if self.0.fd == libc::FAN_NOFD {
return;
}
let e = close(self.0.fd);
if !std::thread::panicking() && e == Err(Errno::EBADF) {
panic!("Closing an invalid file descriptor!");
Expand Down

0 comments on commit 40b54bf

Please sign in to comment.