summaryrefslogtreecommitdiffstats
path: root/man/man3/getgrouplist.3
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--man/man3/getgrouplist.3 (renamed from man3/getgrouplist.3)11
1 files changed, 8 insertions, 3 deletions
diff --git a/man3/getgrouplist.3 b/man/man3/getgrouplist.3
index 33e344d..4a8f5fb 100644
--- a/man3/getgrouplist.3
+++ b/man/man3/getgrouplist.3
@@ -7,7 +7,7 @@
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
-.TH getgrouplist 3 2024-03-16 "Linux man-pages 6.7"
+.TH getgrouplist 3 2024-05-02 "Linux man-pages (unreleased)"
.SH NAME
getgrouplist \- get list of groups to which a user belongs
.SH LIBRARY
@@ -134,6 +134,7 @@ ngroups = 3
\&
.\" SRC BEGIN (getgrouplist.c)
.EX
+#include <errno.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
@@ -162,10 +163,14 @@ main(int argc, char *argv[])
\&
/* Fetch passwd structure (contains first group ID for user). */
\&
+ errno = 0;
pw = getpwnam(argv[1]);
if (pw == NULL) {
- perror("getpwnam");
- exit(EXIT_SUCCESS);
+ if (errno)
+ perror("getpwnam");
+ else
+ fprintf(stderr, "no such user\en");
+ exit(EXIT_FAILURE);
}
\&
/* Retrieve group list. */