[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Base Operating System and Extensions Technical Reference, Volume 1

getgroups Subroutine

Purpose

Gets the supplementary group ID of the current process.

Library

Standard C Library (libc.a)

Syntax

#include <sys/types.h>
#include <unistd.h>
int getgroups (NGroups, GIDSet)
int NGroups;
gid_t GIDSet [ ];

Description

The getgroups subroutine gets the supplementary group ID of the process. The list is stored in the array pointed to by the GIDSet parameter. The NGroups parameter indicates the number of entries that can be stored in this array. The getgroups subroutine never returns more than the number of entries specified by the NGROUPS_MAX constant. (The NGROUPS_MAX constant is defined in the limits.h file.) If the value in the NGroups parameter is 0, the getgroups subroutine returns the number of groups in the supplementary group.

Parameters

GIDSet Points to the array in which the supplementary group ID of the user's process is stored.
NGroups Indicates the number of entries that can be stored in the array pointed to by the GIDSet parameter.

Return Values

Upon successful completion, the getgroups subroutine returns the number of elements stored into the array pointed to by the GIDSet parameter. If the getgroups subroutine is unsuccessful, a value of -1 is returned and the errno global variable is set to indicate the error.

Error Codes

The getgroups subroutine is unsuccessful if either of the following error codes is true:

EFAULT The NGroups and GIDSet parameters specify an array that is partially or completely outside of the allocated address space of the process.
EINVAL The NGroups parameter is smaller than the number of groups in the supplementary group.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The getgid subroutine, initgroups subroutine, setgid subroutine, setgroups subroutine.

The groups command, setgroups command.

List of Security and Auditing Subroutines and Subroutines Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]