![]() |
![]() |
![]() |
Get information about the group with a given ID
#include <sys/types.h> #include <grp.h> int getgrgid_r ( gid_t gid, struct group* grp, char* buffer, size_t bufsize, struct group** result );
libc
If _POSIX_THREAD_SAFE_FUNCTIONS is defined, getgrgid_r() updates the group structure pointed by grp and stores a pointer to that structure at the location pointed by result. The structure contains an entry from the group database with a matching gid or name. Storage referenced by the group structure is allocated from the memory provided with the buffer parameter, which is bufsize characters in size. The maximum size needed for this buffer can be determined with the _SC_GETGR_R_SIZE_MAX sysconf() parameter. A NULL pointer is returned at the location pointed by result on error or if the requested entry is not found.
Zero for success, or an error number if an error occurred.
The getgrgid_r() function uses the following functions, and as a result errno can be set to a valid error for any of these calls:
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
getgrgid(), getgrnam(), getgrnam_r(), getlogin(), sysconf()
![]() |
![]() |
![]() |