From 4050072da21cc3106d0985281d75978c07e22abc Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 19 Nov 2024 10:14:32 -0700 Subject: [PATCH] fix warning --- filedescriptor/src/unix.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/filedescriptor/src/unix.rs b/filedescriptor/src/unix.rs index e88cecd16..5c8672cab 100644 --- a/filedescriptor/src/unix.rs +++ b/filedescriptor/src/unix.rs @@ -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)