summaryrefslogtreecommitdiff
path: root/src/passwd/getpwent_a.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/passwd/getpwent_a.c')
-rw-r--r--src/passwd/getpwent_a.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/passwd/getpwent_a.c b/src/passwd/getpwent_a.c
index 34842a07..4d84f0d5 100644
--- a/src/passwd/getpwent_a.c
+++ b/src/passwd/getpwent_a.c
@@ -8,14 +8,16 @@ static unsigned atou(char **s)
return x;
}
-struct passwd *__getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *size)
+int __getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *size, struct passwd **res)
{
ssize_t l;
char *s;
+ int rv = 0;
int cs;
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
for (;;) {
if ((l=getline(line, size, f)) < 0) {
+ rv = errno;
free(*line);
*line = 0;
pw = 0;
@@ -46,5 +48,7 @@ struct passwd *__getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *siz
break;
}
pthread_setcancelstate(cs, 0);
- return pw;
+ *res = pw;
+ if (rv) errno = rv;
+ return rv;
}