Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

getgrgid_r - get group file entry for group ID (thread-safe)

&pagelevel(4)&pagelevel

Syntax

#include <grp.h>

int getgrgid_r(gid_t gid, struct group *grp, char *buffer,

size_t bufsize, struct group **result);

Description  The getgrgid_r() updates the group structure pointed to by grp and stores a pointer to

this structure at the address pointed to by result. The structure contains the entry from the
group file whose gr_gid component matches the gid. The structure found in the group file
is copied to the memory area of length bufsize passed in the buffer parameter.
The maximum size required for this buffer can be determined via the sysconf() parameter
{_SC_GETGR_R_SIZE_MAX}. When an error occurs or when the desired entry could not be
found, a null pointer is returned in the data area pointed to by result.

Return val.

0

Error number

if successful.

if an error occurs. errno is set to indicate the error.

Errors

The getgrgid_r() function fails if:

ERANGE

The memory area pointed to by buffer of length bufsize is not large enough
to hold the data pointed to by the resulting group structure.

Notes

Applications in which there are checks for error situations must set errno to 0 before calling
getgrgid_r(). If errno is set to a value not equal to null when it returns, then an error
occurred.

See also

getgrgid(), getgrnam(), grp.h, limits.h, sys/types.h.