Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ mod tests {
let file = File::open("testdata/file1.txt").unwrap();
let file_fd: OwnedFd = file.into();
let raw_file_fd = file_fd.as_raw_fd();
assert!(raw_file_fd > 3);
assert!(raw_file_fd > 2);
command.preserved_fds(vec![file_fd]);

let output = command.output().unwrap();
Expand Down Expand Up @@ -416,11 +416,16 @@ mod tests {
/// This is necessary because GitHub Actions opens a bunch of others for some reason.
fn close_excess_fds() {
let dir = read_dir("/proc/self/fd").unwrap();
for entry in dir {
let entry = entry.unwrap();
let fd: RawFd = entry.file_name().to_str().unwrap().parse().unwrap();
if fd > 3 {
close(fd).unwrap();
let fds: Vec<RawFd> = dir
.map(|entry| {
let entry = entry.unwrap();
entry.file_name().to_str().unwrap().parse().unwrap()
})
.collect();
for fd in fds {
if fd > 2 {
// Ignore errors, as the file may already be closed.
let _ = close(fd);
}
}
}
Expand Down