summaryrefslogtreecommitdiffstats
path: root/man3/getgrouplist.3
diff options
context:
space:
mode:
Diffstat (limited to 'man3/getgrouplist.3')
-rw-r--r--man3/getgrouplist.39
1 files changed, 7 insertions, 2 deletions
diff --git a/man3/getgrouplist.3 b/man3/getgrouplist.3
index 5e11b426b..61d3b7a9b 100644
--- a/man3/getgrouplist.3
+++ b/man3/getgrouplist.3
@@ -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. */