summaryrefslogtreecommitdiff
path: root/libc/pwd_grp/fgetgrent.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-08-18 18:50:52 +0000
committerEric Andersen <andersen@codepoet.org>2002-08-18 18:50:52 +0000
commit160212fe2d074af5bdc25b219e2276576f52b6e3 (patch)
treea18295e8f38e392f16191e4e8480a8caf25a66dc /libc/pwd_grp/fgetgrent.c
parented43cbaf96c89d13675d2afeb8c73109982c64d9 (diff)
Yet more rework to make __getgrent and the functions that use it
reentrant... -Erik
Diffstat (limited to 'libc/pwd_grp/fgetgrent.c')
-rw-r--r--libc/pwd_grp/fgetgrent.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/libc/pwd_grp/fgetgrent.c b/libc/pwd_grp/fgetgrent.c
index 327802b86..b99df1c77 100644
--- a/libc/pwd_grp/fgetgrent.c
+++ b/libc/pwd_grp/fgetgrent.c
@@ -21,13 +21,30 @@
#include <stdio.h>
#include <errno.h>
#include "config.h"
+
+#ifdef __UCLIBC_HAS_THREADS__
+#include <pthread.h>
+static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
+# define LOCK pthread_mutex_lock(&mylock)
+# define UNLOCK pthread_mutex_unlock(&mylock);
+#else
+# define LOCK
+# define UNLOCK
+#endif
+static char *line_buff = NULL;
+static char **members = NULL;
struct group *fgetgrent(FILE * file)
{
- if (file == NULL) {
- __set_errno(EINTR);
- return NULL;
- }
+ struct group *grp;
- return __getgrent(fileno(file));
+ if (file == NULL) {
+ __set_errno(EINTR);
+ return NULL;
+ }
+
+ LOCK;
+ grp = __getgrent(fileno(file), line_buff, members);
+ UNLOCK;
+ return grp;
}