diff options
author | Simon Marlow <marlowsd@gmail.com> | 2010-03-29 11:27:13 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2010-03-29 11:27:13 +0000 |
commit | 714fa064dcc57b7c7e3cdeb1f62c9f36cfea6e51 (patch) | |
tree | b834d9717027857ac1de128ecc07852875bd8c38 /System | |
parent | 07ad49a59d2bf20fc8b4e835c42726c687e98380 (diff) |
make getAllGroupEntries work when called again; fixes #3816
Diffstat (limited to 'System')
-rw-r--r-- | System/Posix/User.hsc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/System/Posix/User.hsc b/System/Posix/User.hsc index 2427de0..e1c0f95 100644 --- a/System/Posix/User.hsc +++ b/System/Posix/User.hsc @@ -222,7 +222,7 @@ getGroupEntryForName = error "System.Posix.User.getGroupEntryForName: not suppor getAllGroupEntries :: IO [GroupEntry] #ifdef HAVE_GETGRENT getAllGroupEntries = - withMVar lock $ \_ -> worker [] + withMVar lock $ \_ -> bracket_ c_setgrent c_endgrent $ worker [] where worker accum = do resetErrno ppw <- throwErrnoIfNullAndError "getAllGroupEntries" $ @@ -234,6 +234,10 @@ getAllGroupEntries = foreign import ccall unsafe "getgrent" c_getgrent :: IO (Ptr CGroup) +foreign import ccall unsafe "setgrent" + c_setgrent :: IO () +foreign import ccall unsafe "endgrent" + c_endgrent :: IO () #else getAllGroupEntries = error "System.Posix.User.getAllGroupEntries: not supported" #endif |