#include <sys/types.h> #include <grp.h> struct group *getgrgid(gid_t gid);
getgrgid
provides information about a group and its members.
gid
is the group ID. getgrgid
returns a pointer to a
group
structure defined in <grp.h>
that contains an entry from
the group database. group
contains the following members:
gr_name
gr_gid
gr_mem
getgrgid
returns a pointer to a group
structure if
successful.
getgrgid
returns a NULL
pointer if unsuccessful.
Note:
The pointer returned by
getgrgid
may be a static data area that can be rewritten by the
next call to getgrgid
or getgrnam
.
getgrgid
to obtain a group name:
#include <sys/types.h> #include <stdio.h> #include <grp.h> #include <sys/stat.h> . . . struct stat info; struct group *grp; . . . if ((grp = getgrgid(info.st_gid)) == NULL) perror("getgrgid() error"); else printf("The group name is %sn", grp->gr_name); . . .
getgrnam
, getgroups
, getpwuid
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.