diff options
author | Joey Hess <joey@kitenet.net> | 2012-06-18 19:14:58 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-06-18 19:14:58 -0400 |
commit | ae7d07ddcb5768cf477410e019d42601d8c2b744 (patch) | |
tree | 7910a3b42f24d2e260b26d7e569a8aa2d8c78f74 /Utility | |
parent | 1f6d80007c0cb9bca21bc744c8e2388e2f0fa8bc (diff) |
close fds
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/Kqueue.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Utility/Kqueue.hs b/Utility/Kqueue.hs index 6da97d3fa..d0b3c8a99 100644 --- a/Utility/Kqueue.hs +++ b/Utility/Kqueue.hs @@ -45,8 +45,12 @@ addSubDir :: DirMap -> FilePath -> (FilePath -> Bool) -> IO DirMap addSubDir dirmap dir prune = M.union dirmap <$> scanRecursive dir prune {- Removes a subdirectory (and all its subdirectories) from a directory map. -} -removeSubDir :: FilePath -> DirMap -> DirMap -removeSubDir dir = M.filter (not . dirContains dir) +removeSubDir :: FilePath -> DirMap -> IO DirMap +removeSubDir dir dirmap = do + mapM_ closeFd $ M.keys toremove) $ closeFd + return rest + where + (toremove, rest) = M.partition (dirContains dir) dirmap foreign import ccall unsafe "libkqueue.h init_kqueue" c_init_kqueue :: CInt -> Ptr Fd -> IO Fd |