MCPcopy Index your code
hub / github.com/RustPython/RustPython / dup2

Function dup2

crates/vm/src/stdlib/posix.rs:2052–2060  ·  view source on GitHub ↗
(args: Dup2Args<'_>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2050
2051 #[pyfunction]
2052 fn dup2(args: Dup2Args<'_>, vm: &VirtualMachine) -> PyResult<OwnedFd> {
2053 let mut fd2 = core::mem::ManuallyDrop::new(args.fd2);
2054 nix::unistd::dup2(args.fd, &mut fd2).map_err(|e| e.into_pyexception(vm))?;
2055 let fd2 = core::mem::ManuallyDrop::into_inner(fd2);
2056 if !args.inheritable {
2057 super::set_inheritable(fd2.as_fd(), false).map_err(|e| e.into_pyexception(vm))?
2058 }
2059 Ok(fd2)
2060 }
2061
2062 pub(crate) fn support_funcs() -> Vec<SupportFunc> {
2063 vec![

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
set_inheritableFunction · 0.70
into_pyexceptionMethod · 0.45
as_fdMethod · 0.45

Tested by

no test coverage detected