getgroups() - retrieve supplementary group ID list
#include <sys/types.h>
#include <unistd.h>
int getgroups (int gidsetsize, gid_t grouplist[])
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.
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.
The getgroups(2) function fails because:
getgrnam(2)
getpwnam(2)