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

Function close_fds_brute_force

crates/stdlib/src/posixsubprocess.rs:509–522  ·  view source on GitHub ↗
(keep: KeepFds<'_>)

Source from the content-addressed store, hash-verified

507}
508
509fn close_fds_brute_force(keep: KeepFds<'_>) {
510 let max_fd = nix::unistd::sysconf(nix::unistd::SysconfVar::OPEN_MAX)
511 .ok()
512 .flatten()
513 .unwrap_or(256) as i32;
514 let fds = itertools::chain![
515 Some(keep.above),
516 keep.keep.iter().map(BorrowedFd::as_raw_fd),
517 Some(max_fd)
518 ];
519 for fd in fds.tuple_windows().flat_map(|(start, end)| start + 1..end) {
520 unsafe { libc::close(fd) };
521 }
522}
523
524#[derive(Default)]
525struct IntParser {

Callers 1

close_fdsFunction · 0.85

Calls 4

sysconfFunction · 0.85
okMethod · 0.80
closeFunction · 0.70
flattenMethod · 0.45

Tested by

no test coverage detected