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

Function set_inheritable

crates/common/src/fileutils.rs:515–532  ·  view source on GitHub ↗
(fd: libc::c_int, inheritable: bool)

Source from the content-addressed store, hash-verified

513// Only used on Windows; Unix automatically sets O_CLOEXEC
514#[cfg(windows)]
515fn set_inheritable(fd: libc::c_int, inheritable: bool) -> std::io::Result<()> {
516 use windows_sys::Win32::Foundation::{
517 HANDLE, HANDLE_FLAG_INHERIT, INVALID_HANDLE_VALUE, SetHandleInformation,
518 };
519
520 let handle = unsafe { libc::get_osfhandle(fd) };
521 if handle == INVALID_HANDLE_VALUE as isize {
522 return Err(std::io::Error::last_os_error());
523 }
524
525 let flags = if inheritable { HANDLE_FLAG_INHERIT } else { 0 };
526 let result = unsafe { SetHandleInformation(handle as HANDLE, HANDLE_FLAG_INHERIT, flags) };
527 if result == 0 {
528 return Err(std::io::Error::last_os_error());
529 }
530
531 Ok(())
532}

Callers 1

fopenFunction · 0.70

Calls 2

get_osfhandleFunction · 0.85
ErrClass · 0.50

Tested by

no test coverage detected