getgroups()

NAME

getgroups() - retrieve supplementary group ID list

SYNOPSIS

#include <sys/types.h>
#include <unistd.h>

int getgroups (int gidsetsize, gid_t grouplist[])

DESCRIPTION

The getgroups(2) function reads through the group database and fills the grouplist array with the supplementary group IDs of the calling process.

The argument gidsetsize specifies the number of elements in the supplied array.

To determine the number of supplemental group IDs associated with the calling process, set gidsetsize to 0.

On Windows, groups and users share the same name space in the user accounts database.

RETURN VALUES

The getgroups(2) function returns the number of supplementary group IDs filled in the grouplist array.

On error, it returns -1. The group array will be filled with as many groups as will fit.

ERRORS

The getgroups(2) function fails because:

[EINVAL]
The gidsetsize argument isn't equal to 0 and is less than the number of supplementary group IDs.

SEE ALSO

getgrnam(2)

getpwnam(2)