@@ -941,6 +941,26 @@ pub fn setgid(gid: Gid) -> Result<()> {
941
941
Errno :: result ( res) . map ( drop)
942
942
}
943
943
944
+ #[ inline]
945
+ pub fn setgroups ( groups : & [ Gid ] ) -> Result < ( ) > {
946
+ cfg_if ! {
947
+ if #[ cfg( any( target_os = "macos" ,
948
+ target_os = "ios" ,
949
+ target_os = "freebsd" ,
950
+ target_os = "dragonfly" ,
951
+ target_os = "openbsd" ,
952
+ target_os = "netbsd" ) ) ] {
953
+ type setgroups_ngroups_t = c_int;
954
+ } else {
955
+ type setgroups_ngroups_t = size_t;
956
+ }
957
+ }
958
+ let gids: Vec < gid_t > = groups. iter ( ) . cloned ( ) . map ( Into :: into) . collect ( ) ;
959
+ let res = unsafe { libc:: setgroups ( groups. len ( ) as setgroups_ngroups_t , gids. as_ptr ( ) ) } ;
960
+
961
+ Errno :: result ( res) . map ( drop)
962
+ }
963
+
944
964
#[ inline]
945
965
pub fn pause ( ) -> Result < ( ) > {
946
966
let res = unsafe { libc:: pause ( ) } ;
@@ -1248,7 +1268,7 @@ pub enum SysconfVar {
1248
1268
OPEN_MAX = libc:: _SC_OPEN_MAX,
1249
1269
#[ cfg( any( target_os="dragonfly" , target_os="freebsd" , target_os = "ios" ,
1250
1270
target_os="linux" , target_os = "macos" , target_os="openbsd" ) ) ]
1251
- /// The implementation supports the Advisory Information option.
1271
+ /// The implementation supports the Advisory Information option.
1252
1272
_POSIX_ADVISORY_INFO = libc:: _SC_ADVISORY_INFO,
1253
1273
#[ cfg( any( target_os="dragonfly" , target_os="freebsd" , target_os = "ios" ,
1254
1274
target_os="linux" , target_os = "macos" , target_os="netbsd" ,
@@ -1267,7 +1287,7 @@ pub enum SysconfVar {
1267
1287
target_os="openbsd" ) ) ]
1268
1288
/// The implementation supports the Process CPU-Time Clocks option.
1269
1289
_POSIX_CPUTIME = libc:: _SC_CPUTIME,
1270
- /// The implementation supports the File Synchronization option.
1290
+ /// The implementation supports the File Synchronization option.
1271
1291
_POSIX_FSYNC = libc:: _SC_FSYNC,
1272
1292
#[ cfg( any( target_os="dragonfly" , target_os="freebsd" , target_os = "ios" ,
1273
1293
target_os="linux" , target_os = "macos" , target_os="openbsd" ) ) ]
@@ -1382,7 +1402,7 @@ pub enum SysconfVar {
1382
1402
target_os="linux" , target_os = "macos" , target_os="openbsd" ) ) ]
1383
1403
/// The implementation supports timeouts.
1384
1404
_POSIX_TIMEOUTS = libc:: _SC_TIMEOUTS,
1385
- /// The implementation supports timers.
1405
+ /// The implementation supports timers.
1386
1406
_POSIX_TIMERS = libc:: _SC_TIMERS,
1387
1407
#[ cfg( any( target_os="dragonfly" , target_os="freebsd" , target_os = "ios" ,
1388
1408
target_os="linux" , target_os = "macos" , target_os="openbsd" ) ) ]
0 commit comments