From d1bc9ce0a065ec8df38725a0a806cefe09241e6f Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 17 Apr 2024 20:10:39 -0600 Subject: [PATCH] Ignore errors in Drop for unix::fs::Dir Fixes #124105 --- library/std/src/sys/pal/unix/fs.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/library/std/src/sys/pal/unix/fs.rs b/library/std/src/sys/pal/unix/fs.rs index 3456155509ef3..92b23d517d012 100644 --- a/library/std/src/sys/pal/unix/fs.rs +++ b/library/std/src/sys/pal/unix/fs.rs @@ -870,12 +870,9 @@ impl Iterator for ReadDir { impl Drop for Dir { fn drop(&mut self) { - let r = unsafe { libc::closedir(self.0) }; - assert!( - r == 0 || crate::io::Error::last_os_error().is_interrupted(), - "unexpected error during closedir: {:?}", - crate::io::Error::last_os_error() - ); + // Note that errors are ignored when closing a directory as we have + // no non-destructive way to report it. See #124105 and #98338. + let _ = unsafe { libc::closedir(self.0) }; } }