Skip to content

Commit de9b744

Browse files
committed
unix process: Use BorrowedFd::try_clone_to_owned
1 parent 5a715aa commit de9b744

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

library/std/src/sys/unix/process/process_common.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::collections::BTreeMap;
77
use crate::ffi::{CStr, CString, OsStr, OsString};
88
use crate::fmt;
99
use crate::io;
10-
use crate::mem::ManuallyDrop;
1110
use crate::path::Path;
1211
use crate::ptr;
1312
use crate::sys::fd::FileDesc;
@@ -466,13 +465,7 @@ impl Stdio {
466465
}
467466

468467
Stdio::StaticFd(fd) => {
469-
let fd = unsafe {
470-
// Unfortunately there is no public method to dup BorrwedFd into an OwnedFd !
471-
// https://github.com/rust-lang/rust/issues/88564#issuecomment-916460459
472-
let fd = fd.as_raw_fd();
473-
let fd = ManuallyDrop::new(FileDesc::from_inner(OwnedFd::from_raw_fd(fd)));
474-
fd.duplicate()?
475-
};
468+
let fd = FileDesc::from_inner(fd.try_clone_to_owned()?);
476469
Ok((ChildStdio::Owned(fd), None))
477470
}
478471

0 commit comments

Comments
 (0)