1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" References consulted:
6 .\" Linux libc source code
7 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
9 .\" Modified Sat Jul 24 19:29:54 1993 by Rik Faith (faith@cs.unc.edu)
10 .TH GETGRENT 3 2021-03-22 "Linux man-pages (unreleased)"
12 getgrent, setgrent, endgrent \- get group file entry
15 .RI ( libc ", " \-lc )
18 .B #include <sys/types.h>
21 .B struct group *getgrent(void);
23 .B void setgrent(void);
24 .B void endgrent(void);
28 Feature Test Macro Requirements for glibc (see
29 .BR feature_test_macros (7)):
35 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
36 || /* Glibc since 2.19: */ _DEFAULT_SOURCE
37 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
44 _XOPEN_SOURCE >= 500 || _DEFAULT_SOURCE
45 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
46 Glibc 2.21 and earlier
48 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
49 || /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
50 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
55 function returns a pointer to a structure containing
56 the broken-out fields of a record in the group database
57 (e.g., the local group file
63 it returns the first entry; thereafter, it returns successive entries.
67 function rewinds to the beginning
68 of the group database, to allow repeated scans.
72 function is used to close the group database
73 after all processing has been performed.
75 The \fIgroup\fP structure is defined in \fI<grp.h>\fP as follows:
80 char *gr_name; /* group name */
81 char *gr_passwd; /* group password */
82 gid_t gr_gid; /* group ID */
83 char **gr_mem; /* NULL\-terminated array of pointers
84 to names of group members */
89 For more information about the fields of this structure, see
94 function returns a pointer to a
97 or NULL if there are no more entries or an error occurs.
102 If one wants to check
104 after the call, it should be set to zero before the call.
106 The return value may point to a static area, and may be overwritten
107 by subsequent calls to
112 (Do not pass the returned pointer to
117 The service was temporarily unavailable; try again later.
118 For NSS backends in glibc
119 this indicates a temporary error talking to the backend.
120 The error may correct itself, retrying later is suggested.
123 A signal was caught; see
130 The per-process limit on the number of open file descriptors has been reached.
133 The system-wide limit on the total number of open files has been reached.
137 A necessary input file cannot be found.
138 For NSS backends in glibc
139 this indicates the backend is not correctly configured.
143 Insufficient memory to allocate
148 Insufficient buffer space supplied.
152 local group database file
154 For an explanation of the terms used in this section, see
162 Interface Attribute Value
173 MT-Unsafe race:grent locale
184 signifies that if any of the functions
189 are used in parallel in different threads of a program,
190 then data races could occur.
192 POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
198 .BR getgrouplist (3),