Skip to content

Commit f32147b

Browse files
committed
Don't close the directory while we're still reading it.
1 parent 690564c commit f32147b

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

0 commit comments

Comments
 (0)