MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / dup2_stdout

Function dup2_stdout

src/stdio.rs:500–509  ·  view source on GitHub ↗
(fd: Fd)

Source from the content-addressed store, hash-verified

498#[cfg(not(any(windows, target_os = "wasi")))]
499#[inline]
500pub fn dup2_stdout<Fd: AsFd>(fd: Fd) -> io::Result<()> {
501 let fd = fd.as_fd();
502 if fd.as_raw_fd() != c::STDOUT_FILENO {
503 // SAFETY: We wrap the returned `OwnedFd` to `ManuallyDrop` so that it
504 // isn't dropped.
505 let mut target = ManuallyDrop::new(unsafe { take_stdout() });
506 backend::io::syscalls::dup2(fd, &mut target)?;
507 }
508 Ok(())
509}
510
511/// Utility function to safely `dup2` over stderr (fd 2).
512#[cfg(not(any(windows, target_os = "wasi")))]

Callers 2

dup2_stdout_stdoutFunction · 0.85
mainFunction · 0.85

Calls 4

take_stdoutFunction · 0.85
dup2Function · 0.50
as_fdMethod · 0.45
as_raw_fdMethod · 0.45

Tested by 1

dup2_stdout_stdoutFunction · 0.68