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

Function dup

crates/vm/src/stdlib/nt.rs:2117–2127  ·  view source on GitHub ↗
(fd: i32, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2115
2116 #[pyfunction]
2117 fn dup(fd: i32, vm: &VirtualMachine) -> PyResult<i32> {
2118 let fd2 = unsafe { suppress_iph!(libc::dup(fd)) };
2119 if fd2 < 0 {
2120 return Err(vm.new_last_errno_error());
2121 }
2122 let borrowed = unsafe { crt_fd::Borrowed::borrow_raw(fd2) };
2123 let handle = crt_fd::as_handle(borrowed).map_err(|e| close_fd_and_raise(fd2, e, vm))?;
2124 raw_set_handle_inheritable(handle.as_raw_handle() as _, false)
2125 .map_err(|e| close_fd_and_raise(fd2, e, vm))?;
2126 Ok(fd2)
2127 }
2128
2129 #[derive(FromArgs)]
2130 struct Dup2Args {

Callers 4

listdirFunction · 0.70
scandirFunction · 0.70
dupMethod · 0.50
fromfdFunction · 0.50

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