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

Function dup2

crates/vm/src/stdlib/nt.rs:2140–2153  ·  view source on GitHub ↗
(args: Dup2Args, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2138
2139 #[pyfunction]
2140 fn dup2(args: Dup2Args, vm: &VirtualMachine) -> PyResult<i32> {
2141 let result = unsafe { suppress_iph!(libc::dup2(args.fd, args.fd2)) };
2142 if result < 0 {
2143 return Err(vm.new_last_errno_error());
2144 }
2145 if !args.inheritable {
2146 let borrowed = unsafe { crt_fd::Borrowed::borrow_raw(args.fd2) };
2147 let handle =
2148 crt_fd::as_handle(borrowed).map_err(|e| close_fd_and_raise(args.fd2, e, vm))?;
2149 raw_set_handle_inheritable(handle.as_raw_handle() as _, false)
2150 .map_err(|e| close_fd_and_raise(args.fd2, e, vm))?;
2151 }
2152 Ok(args.fd2)
2153 }
2154
2155 /// Windows-specific readlink that preserves \\?\ prefix for junctions
2156 /// returns the substitute name from reparse data which includes the prefix

Callers

nothing calls this directly

Calls 5

as_handleFunction · 0.85
close_fd_and_raiseFunction · 0.85
new_last_errno_errorMethod · 0.80
ErrClass · 0.50

Tested by

no test coverage detected