We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f4a665f commit f2ada86Copy full SHA for f2ada86
src/unistd.rs
@@ -954,9 +954,11 @@ pub fn getgroups() -> Result<Vec<Gid>> {
954
// First get the number of groups so we can size our Vec
955
use std::ptr;
956
let ret = unsafe { libc::getgroups(0, ptr::null_mut()) };
957
- let mut size = try!(Errno::result(ret));
+ let mut size = Errno::result(ret)?;
958
959
- // Now actually get the groups
+ // Now actually get the groups. We try multiple times in case the number of
960
+ // groups has changed since the first call to getgroups() and the buffer is
961
+ // now too small
962
let mut groups = Vec::<Gid>::with_capacity(size as usize);
963
loop {
964
// We can coerce a pointer to some `Gid`s as a pointer to some `gid_t`s
0 commit comments