Skip select ebadf test under WSLv1 due to a WSL bug

WSLv1 won't return EBADF (or any error) if the fd was closed mid-select.
This commit is contained in:
Mahmoud Al-Qudsi 2025-01-09 17:30:08 -06:00
parent 0fcb2f7590
commit c1a43b896c
2 changed files with 8 additions and 1 deletions

View file

@ -384,6 +384,8 @@ impl BackgroundFdMonitor {
// in particular it may even close file descriptors that we are waiting on. That is why
// we handle EBADF. Note that even if the file descriptor is recycled, we don't invoke
// a callback for it unless its ItemID is still present.
//
// Note that WSLv1 doesn't throw EBADF if the fd is closed is mid-select.
drop(data);
let ret = fds.check_readable(
timeout

View file

@ -204,13 +204,18 @@ where
#[test]
fn test_close_during_select_ebadf() {
use crate::common::{is_windows_subsystem_for_linux as is_wsl, WSL};
let close_it = |read_fd: OwnedFd| {
drop(read_fd);
None
};
let result = do_something_bad_during_select(close_it);
// WSLv1 does not error out with EBADF if the fd is closed mid-select.
// This is OK because we do not _depend_ on this behavior; the only
// true requirement is that we don't panic in the handling code above.
assert!(
matches!(result, Err(libc::EBADF) | Ok(1)),
is_wsl(WSL::V1) || matches!(result, Err(libc::EBADF) | Ok(1)),
"select/poll should have failed with EBADF or marked readable"
);
}