fgetgrent(3)
π fgetgrent(3) β get group file entry π
okay bestie, pull up a chair, we're doing a libc deep dive and honestly? it's giving β¨group fileβ¨ energy. this is the Library Functions Manual entry for fgetgrent, and by the end of this you're gonna know her like she's your mutual on the group chat. no cap. π«Ά
πΈ NAME πΈ
fgetgrent β get group file entry
like. that's it. that's the whole job description. she reads group entries. iconic behavior tbh. π
π LIBRARY π
Standard C library (libc, -lc)
β¨ SYNOPSIS β¨
okay so here's the summoning ritual, copy it EXACTLY bestie, no typos, the compiler is not forgiving and she will ghost you if you fumble it:
#include <stdio.h>
#include <sys/types.h>
#include <grp.h>
struct group *fgetgrent(FILE *stream);
π Feature Test Macro Requirements for glibc π
(peep feature_test_macros(7) if you wanna know more, iykyk)
fgetgrent():
- Since glibc 2.19:
_DEFAULT_SOURCE
- glibc 2.19 and earlier:
_SVID_SOURCE
so like, depending on how old your glibc is, you gotta define a different little magic word before your includes or she just will NOT exist. vintage glibc girlies stay winning i guess π
π¦ DESCRIPTION π¦
So fgetgrent() hands you back a pointer to a structure that's holding all the group info from the file that stream points at. π
First time you call her? She gives you the first entry. Every call after that? She gives you the successive ones, one at a time, like she's flipping through a lil scrapbook. π
Tiny but important: the file thatstreamrefers to must have the same format as/etc/groupβ go checkgroup(5)for the deets, bestie.
And the group structure? She lives in <grp.h> and she looks like THIS, character for character, do not touch her:
struct group {
char *gr_name; /* group name */
char *gr_passwd; /* group password */
gid_t gr_gid; /* group ID */
char **gr_mem; /* NULL-terminated array of pointers
to names of group members */
};
the gr_mem field is a NULL-terminated array of pointers to names of group members, which is a very fancy way of saying "a list that stops when it hits NULL". main character detail honestly. β¨
π RETURN VALUE π
fgetgrent() returns a pointer to a group structure. slay.
But if there are no more entries, or an error happens? She returns NULL. and if it's an error situation, errno gets set to tell you what went wrong. so like, check your errno bestie, she's trying to communicate with you π
π ERRORS π
ENOMEMβ not enough memory to allocate the group structure. she's out of room, it's a whole thing. π
π ATTRIBUTES π
for the full explanation of what these terms even mean, go read attributes(7), we're just vibing with the summary here:
- Interface:
fgetgrent()- Attribute: Thread safety
- Value:
MT-Unsafe race:fgetgrent
π¨ okay this one MATTERS: MT-Unsafe race:fgetgrent means she is NOT thread safe. there's a race condition situation going on. don't be out here calling her from multiple threads and expecting peace and harmony. that's the drama. π«
π STANDARDS π
None.
yeah. she's not standardized. she's just out here existing on vibes. π
β HISTORY β
SVr4.
an elder. a legend. she's been around. respect her. π
π§ SEE ALSO π§
go read these next, bestie, they're all in the group chat:
endgrent(3)fgetgrent_r(3)fopen(3)getgrent(3)getgrgid(3)getgrnam(3)putgrent(3)setgrent(3)group(5)
and that's the whole page, bestie!! π this was Linux man-pages 6.20, dated 2026-02-08, and it lives in section 3 of your friendly neighborhood fgetgrent(3) man page. mwah. go read your group files responsibly. πβ¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms