getgroups(2)getgroups(2)NAMEgetgroups - get supplementary group access list IDs
SYNOPSIS
#include <unistd.h>
int ngrps;
POSIX:
ngrps = getgroups(int setlen, gid_t *gidset);
BSD:
ngrps = getgroups(int setlen, int *gidset);
To use the BSD version of getgroups one must either
1) explicitly invoke it as BSDgetgroups or
2) link with the libbsd.a library:
cc -o prog prog.c -lbsd
DESCRIPTIONgetgroups retrieves the current group access list of the user process and
stores it in the array gidset. The parameter setlen indicates the number
of entries that may be placed in gidset. The return value is the actual
number of groups placed in gidset, and this will never be greater than
NGROUPS_UMAX for the POSIX version, and NGROUPS for the BSD version, as
defined in <sys/param.h>.
As a special case, if the setlen parameter is zero, getgroups returns the
number of supplemental group IDs associated with the calling process
without modifying the array pointed to by the gidset argument.
RETURN VALUE
A successful call returns the number of groups in the group set. A value
of -1 indicates that an error occurred, and the error code is stored in
the global variable errno.
ERRORS
The possible errors for getgroups are:
[EINVAL] The argument setlen is smaller than the number of groups
in the group set.
[EFAULT] The argument gidset specifies an invalid address.
SEE ALSOmultgrps(1), setgroups(2), initgroups(3)
Page 1
getgroups(2)getgroups(2)CAVEATS
The POSIX and 4.3BSD versions differ in the types of their gidset
parameter.
Page 2