Skip to content

Commit

Permalink
fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
wez committed Nov 19, 2024
1 parent 979df78 commit 4050072
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion filedescriptor/src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ impl FileDescriptor {
};

let std_original = FileDescriptor::dup(&std_descriptor)?;
unsafe { FileDescriptor::dup2(f, std_descriptor) }?.into_raw_fd();
// Assign f into std_descriptor, then convert to an fd so that
// we don't close it when the returned FileDescriptor is dropped.
// Then we discard/ignore the fd because it is nominally owned by
// the stdio machinery for the process
let _ = unsafe { FileDescriptor::dup2(f, std_descriptor) }?.into_raw_fd();
Self::no_cloexec(std_descriptor)?;

Ok(std_original)
Expand Down

0 comments on commit 4050072

Please sign in to comment.