aboutsummaryrefslogtreecommitdiffhomepage
path: root/System/Posix/Error.hs
diff options
context:
space:
mode:
authorGravatar Simon Marlow <marlowsd@gmail.com>2010-01-27 11:46:00 +0000
committerGravatar Simon Marlow <marlowsd@gmail.com>2010-01-27 11:46:00 +0000
commit2e147b0cf3567c5a401670b9bbcd95665aadd024 (patch)
treea3edb2f635324b10da4b20741631026a54634121 /System/Posix/Error.hs
parent6f74df238e660ffeb27d86feaf01222122a296eb (diff)
check for EINTR in openFd
Diffstat (limited to 'System/Posix/Error.hs')
-rw-r--r--System/Posix/Error.hs28
1 files changed, 26 insertions, 2 deletions
diff --git a/System/Posix/Error.hs b/System/Posix/Error.hs
index 1f05b03..cd4b91e 100644
--- a/System/Posix/Error.hs
+++ b/System/Posix/Error.hs
@@ -16,10 +16,34 @@ module System.Posix.Error (
throwErrnoPath,
throwErrnoPathIf,
throwErrnoPathIf_,
+ throwErrnoPathIfRetry,
throwErrnoPathIfNull,
+ throwErrnoPathIfNullRetry,
throwErrnoPathIfMinus1,
- throwErrnoPathIfMinus1_
+ throwErrnoPathIfMinus1_,
+ throwErrnoPathIfMinus1Retry
) where
-import Foreign.C.Error
+import Foreign
+import Foreign.C
+
+throwErrnoPathIfMinus1Retry :: Num a => String -> FilePath -> IO a -> IO a
+throwErrnoPathIfMinus1Retry loc path f =
+ throwErrnoPathIfRetry (== -1) loc path f
+
+throwErrnoPathIfNullRetry :: String -> FilePath -> IO (Ptr a) -> IO (Ptr a)
+throwErrnoPathIfNullRetry loc path f =
+ throwErrnoPathIfRetry (== nullPtr) loc path f
+
+throwErrnoPathIfRetry :: (a -> Bool) -> String -> FilePath -> IO a -> IO a
+throwErrnoPathIfRetry pr loc path f =
+ do
+ res <- f
+ if pr res
+ then do
+ err <- getErrno
+ if err == eINTR
+ then throwErrnoPathIfRetry pr loc path f
+ else throwErrnoPath loc path
+ else return res