getgroups -- get supplementary group ID's


cc . . . -lc

#include  <sys/types.h>

int getgroups (gidsetsize, grouplist) int gidsetsize; gid_t grouplist[];


The getgroups routine fills in the array argument grouplist with the supplementary group IDs of the calling process. This does not include the effective group ID of the calling process itself, unless that is one of the group IDs set by setgroups(S). The argument gidsetsize sets the maximum number of elements in the supplied array grouplist. The actual number of supplementary group IDs is returned. The values of the array entries with indices larger than or equal to the returned value are undefined since the array grouplist will have overflowed.

As a special case, if the argument gidsetsize is zero, getgroups returns the number of supplemental group IDs associated with the calling process without modifying the array to which the argument grouplist points.

Return values

Upon successful completion, the getgroups routine returns the number of supplementary group IDs. This value is zero if {NGROUPS_MAX} is zero. If getgroups fails, a value of -1 is returned and errno is set to indicate the error.


If one of the following conditions occurs, getgroups returns a value of -1 and errno is set to the corresponding value:

The gidsetsize argument is not equal to zero and is less than the number of supplementary group IDs.

See also

getgroups(S), initgroups(S), setgroups(S)

Standards conformance

getgroups conforms with:

X/Open Portability Guide, Issue 3, 1989 ;
IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1) ;
and NIST FIPS 151-1 .

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003