(args: Dup2Args, vm: &VirtualMachine)
| 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 |
nothing calls this directly
no test coverage detected