Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/g/getgroups.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/g/getgroups.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/g/getgroups.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/g/getgroups.html on line 8

getgroups()

Get the supplementary group IDs of the calling process

Synopsis:

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

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

Arguments:

gidsetsize
The size of the grouplist array.
grouplist
An array that the function can fill in with the process's supplementary group IDs.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The getgroups() function fills the array grouplist with the supplementary group IDs of the calling process. The values of array entries with indices greater than or equal to the returned value are undefined.

Returns:

The number of supplementary groups IDs; this value is zero if NGROUPS_MAX is zero. A value of -1 indicates an error (errno is set).

Errors:

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

Examples:

/*
 * Print the supplementary group IDs of
 * the calling process.
 */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main( void )
  {
    int     gidsize;
    gid_t   *grouplist;
    int     i;

    gidsize = getgroups( 0, NULL );
    grouplist = malloc( gidsize * sizeof( gid_t ) );
    getgroups( gidsize, grouplist );
    for( i = 0; i < gidsize; i++ )
      printf( "%d\n", ( int ) grouplist[i] );
    return EXIT_SUCCESS;
  }

Classification:

POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

errno, getegid(), geteuid(), getgid(), getuid(), setgroups()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/g/getgroups.html on line 161

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/g/getgroups.html on line 161