Skip to content

Commit 2d816c4

Browse files
committed
Don't close the directory while we're still reading it.
1 parent 90b2fe2 commit 2d816c4

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
@@ -401,11 +401,16 @@ mod tests {
401401
/// This is necessary because GitHub Actions opens a bunch of others for some reason.
402402
fn close_excess_fds() {
403403
let dir = read_dir("/proc/self/fd").unwrap();
404-
for entry in dir {
405-
let entry = entry.unwrap();
406-
let fd: RawFd = entry.file_name().to_str().unwrap().parse().unwrap();
404+
let fds: Vec<RawFd> = dir
405+
.map(|entry| {
406+
let entry = entry.unwrap();
407+
entry.file_name().to_str().unwrap().parse().unwrap()
408+
})
409+
.collect();
410+
for fd in fds {
407411
if fd > 2 {
408-
close(fd).unwrap();
412+
// Ignore errors, as the file may already be closed.
413+
let _ = close(fd);
409414
}
410415
}
411416
}

0 commit comments

Comments
 (0)