Skip to content

Commit a5ae0bd

Browse files
committed
Don't close the directory while we're still reading it.
1 parent 7e572c0 commit a5ae0bd

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/lib.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,16 @@ mod tests {
416416
/// This is necessary because GitHub Actions opens a bunch of others for some reason.
417417
fn close_excess_fds() {
418418
let dir = read_dir("/proc/self/fd").unwrap();
419-
for entry in dir {
420-
let entry = entry.unwrap();
421-
let fd: RawFd = entry.file_name().to_str().unwrap().parse().unwrap();
419+
let fds: Vec<RawFd> = dir
420+
.map(|entry| {
421+
let entry = entry.unwrap();
422+
entry.file_name().to_str().unwrap().parse().unwrap()
423+
})
424+
.collect();
425+
for fd in fds {
422426
if fd > 2 {
423-
close(fd).unwrap();
427+
// Ignore errors, as the file may already be closed.
428+
let _ = close(fd);
424429
}
425430
}
426431
}

0 commit comments

Comments
 (0)