-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using on MacOS / iOS - semTrywait: invalid argument (Bad file descriptor) #218
Comments
We'll probably have to mark this function as {-# WARNING semOpen
"operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_FDATASYNC@)" #-} So you see this warning at compile time and at runtime simply get an io error. But I'm not sure yet that this is really unsupported. |
Can you try this patch: --- a/System/Posix/Semaphore.hsc
+++ b/System/Posix/Semaphore.hsc
@@ -1,4 +1,5 @@
{-# LANGUAGE Safe #-}
+{-# LANGUAGE CApiFFI #-}
-----------------------------------------------------------------------------
-- |
-- Module : System.Posix.Semaphore
@@ -110,18 +111,18 @@ semGetValue_ sem ptr = do throwErrnoIfMinus1Retry_ "semGetValue" $
cint <- peek ptr
return $ fromEnum cint
-foreign import ccall safe "sem_open"
+foreign import capi safe "semaphore.h sem_open"
sem_open :: CString -> CInt -> CMode -> CUInt -> IO (Ptr ())
-foreign import ccall safe "sem_close"
+foreign import capi safe "semaphore.h sem_close"
sem_close :: Ptr () -> IO CInt
-foreign import ccall safe "sem_unlink"
+foreign import capi safe "semaphore.h sem_unlink"
sem_unlink :: CString -> IO CInt
-foreign import ccall safe "sem_wait"
+foreign import capi safe "semaphore.h sem_wait"
sem_wait :: Ptr () -> IO CInt
-foreign import ccall safe "sem_trywait"
+foreign import capi safe "semaphore.h sem_trywait"
sem_trywait :: Ptr () -> IO CInt
-foreign import ccall safe "sem_post"
+foreign import capi safe "semaphore.h sem_post"
sem_post :: Ptr () -> IO CInt
-foreign import ccall safe "sem_getvalue"
+foreign import capi safe "semaphore.h sem_getvalue"
sem_getvalue :: Ptr () -> Ptr CInt -> IO Int |
I can reproduce it and with my patch above, it seems to work. So this appears to be another instance of: https://www.haskell.org/ghc/blog/20210709-capi-usage.html and #110 (comment) |
haskell#218 Error was: uncaught exception: IOException of type InvalidArgument semTrywait: invalid argument (Bad file descriptor)
haskell#218 Error was: uncaught exception: IOException of type InvalidArgument semTrywait: invalid argument (Bad file descriptor)
haskell#218 Error was: uncaught exception: IOException of type InvalidArgument semTrywait: invalid argument (Bad file descriptor)
* Add regression test for #218 #218 Error was: uncaught exception: IOException of type InvalidArgument semTrywait: invalid argument (Bad file descriptor) * Fix 'semTrywait: invalid argument (Bad file descriptor)' wrt #218 * Add regression test for putEnv wrt #68 * Synchronize ByteString and String modules And fix free-bug in 'putEnv'. Fixes #68 * Add cabal.project * Fix the error handling of posix_fallocate other than FreeBSD This commit introduces a CPP guard to take care of the difference between OSes of the errors of posix_fallocate. On Linux and NetBSD, posix_fallocate reports error by returning an error number. errno is not set. On the other hand, on FreeBSD, posix_fallocate returns -1 and sets errno. The existing code could handle FreeBSD-style errors only. * Remove obsolete FreeBSD-style error handling The FreeBSD-style error (return -1, set errno) is obsolete as of FreeBSD 11.0; it now reports errors as same as the other OSes. * Future-proof glibc version check * Resource: Fix warning in case of no RLIM_SAVED_{CUR,MAX} This previously failed to build with a warning on FreeBSD 11.2 * Bump to 2.7.3 * Add Eq and Show instance to BaudRate Needed for test suite * Add CI * Tighten lower base bound to only allow GHC-8.2+ Co-authored-by: matil019 <[email protected]> Co-authored-by: Viktor Dukhovni <[email protected]> Co-authored-by: Ben Gamari <[email protected]>
Hello!
Is MacOS/iOS supported?
I have:
It fails on semThreadWait:
#43 suggests it might not be working on MacOS?
Thank you!
The text was updated successfully, but these errors were encountered: