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 - get group file entry for group ID

&pagelevel(4)&pagelevel

Syntax

#include <grp.h>

Optional
#include <sys/types.h> (End)

struct group *getgrgid(gid_t gid); 

Description

getgrgid() searches the group file for an entry containing a gr_gid component that
matches gid (see grp.h and the manual "POSIX Basics" [1 (Related publications)]).

getgrgid() is not thread-safe. Use the reentrant function getgrgid_r() when needed.

Return val.

Pointer to an object of the structure group 


if an entry with a gr_gid component matching gid is found.

Null pointer

if an error occurs or no entry with a gr_gid component matching gid is found. errno is set to indicate the error.

Errors

getgrgid() fails if:

 

EIO

EINTR

EMFILE

ENFILE

An I/O error occurred.

A signal was caught during the execution of getgrgid().

Too many file descriptors are currently open in the calling process.

The file table of the system is currently full.

Notes

The return value may point to a static area which may be overwritten by a subsequent call
to getgrgid() or getgrnam().

Since getgrgid() calls functions for file processing that may fail, errno should be set to o
before the call to getgrgid(). If errno is set to some other value on return from the
function, an error has occurred.

See also

getgrgid_r(), getgrnam(), grp.h, limits.h, sys/types.h, and the manual "POSIX Basics" [1 (Related publications)].