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

Function getgrall

crates/stdlib/src/grp.rs:87–102  ·  view source on GitHub ↗
(vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

85
86 #[pyfunction]
87 fn getgrall(vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> {
88 // setgrent, getgrent, etc are not thread safe. Could use fgetgrent_r, but this is easier
89 static GETGRALL: parking_lot::Mutex<()> = parking_lot::Mutex::new(());
90 let _guard = GETGRALL.lock();
91 let mut list = Vec::new();
92
93 unsafe { libc::setgrent() };
94 while let Some(ptr) = NonNull::new(unsafe { libc::getgrent() }) {
95 let group = unistd::Group::from(unsafe { ptr.as_ref() });
96 let group = GroupData::from_unistd_group(group, vm).to_pyobject(vm);
97 list.push(group);
98 }
99 unsafe { libc::endgrent() };
100
101 Ok(list)
102 }
103}

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
lockMethod · 0.45
as_refMethod · 0.45
to_pyobjectMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected