kqueue 0.2 → 0.2.1
raw patch · 2 files changed
+24/−16 lines, 2 filesdep ~basedep ~time
Dependency ranges changed: base, time
Files
- kqueue.cabal +5/−4
- src/System/KQueue.chs +19/−12
kqueue.cabal view
@@ -1,5 +1,5 @@ Name: kqueue-Version: 0.2+Version: 0.2.1 Synopsis: A binding to the kqueue event library. Description: A low-level binding to the kqueue library as found in BSD and Mac OS X. It provides, among@@ -12,7 +12,7 @@ Maintainer: hesselink@gmail.com Category: System Build-type: Simple-Cabal-version: >=1.6+Cabal-version: >=1.10 Extra-source-files: examples/MonitorFile.hs examples/MonitorDirectory.hs CHANGELOG.md@@ -21,14 +21,15 @@ Hs-Source-Dirs: src Exposed-modules: System.KQueue System.KQueue.HighLevel- Build-depends: base >= 4.0 && < 4.10+ Build-depends: base >= 4.0 && < 4.15 , directory >= 1.0 && < 1.4 , filepath >= 1.1 && < 1.5 , mtl >= 1.1 && < 2.3- , time >= 1.1 && < 1.7+ , time >= 1.1 && < 1.12 , unix >= 2.3 && < 2.8 Build-tools: c2hs GHC-Options: -Wall+ Default-language: Haskell2010 Source-Repository head Type: git
src/System/KQueue.chs view
@@ -25,7 +25,7 @@ #if __GLASGOW_HASKELL__ <= 708 import Control.Applicative ( (<$>), (<*>) ) #endif-import Control.Exception ( Exception, throwIO )+import Control.Exception ( Exception, bracket_, throwIO ) import Data.List ( foldl' ) import Data.Maybe ( mapMaybe ) import Data.Time.Clock ( NominalDiffTime )@@ -58,6 +58,10 @@ , CTime , CULong )+import System.Posix.Signals ( blockSignals+ , reservedSignals+ , unblockSignals+ ) -- | A kernel event queue. newtype KQueue = KQueue CInt -- The descriptor@@ -211,14 +215,17 @@ kevent (KQueue kq) changelist nevents mtimeout = withArray changelist $ \chArray -> allocaArray nevents $ \evArray ->- maybeWith with (TimeSpec <$> mtimeout) $ \timeout ->- do ret <- kevent_ kq chArray (fromIntegral . length $ changelist) evArray (fromIntegral nevents) timeout- case ret of- -- Error while processing changelist, and no room in return array.- -1 -> throwIO KQueueException- -- Timeout.- 0 -> return []- -- Returned n events. Can contain errors. The change that- -- failed will be in the event list. EV_ERROR will be set on the- -- event.- n -> peekArray (fromIntegral n) evArray+ maybeWith with (TimeSpec <$> mtimeout) $ \timeout -> do+ ret <- bracket_+ (blockSignals reservedSignals)+ (unblockSignals reservedSignals)+ (kevent_ kq chArray (fromIntegral . length $ changelist) evArray (fromIntegral nevents) timeout)+ case ret of+ -- Error while processing changelist, and no room in return array.+ -1 -> throwIO KQueueException+ -- Timeout.+ 0 -> return []+ -- Returned n events. Can contain errors. The change that+ -- failed will be in the event list. EV_ERROR will be set on the+ -- event.+ n -> peekArray (fromIntegral n) evArray