diff --git a/Crypto/Random/Entropy/Unix.hs b/Crypto/Random/Entropy/Unix.hs index 9a7400c..a8aae43 100644 --- a/Crypto/Random/Entropy/Unix.hs +++ b/Crypto/Random/Entropy/Unix.hs @@ -58,7 +58,7 @@ withDev :: String -> (H -> IO a) -> IO a withDev filepath f = openDev filepath >>= \h -> case h of Nothing -> error ("device " ++ filepath ++ " cannot be grabbed") - Just fd -> f fd >>= \r -> (closeDev fd >> return r) + Just fd -> f fd `E.finally` closeDev fd closeDev :: H -> IO () closeDev h = hClose h