diff options
author | Kamil Dworakowski <kamil@dworakowski.name> | 2020-10-23 14:18:33 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-11-20 02:09:16 -0500 |
commit | b57845c3d80f5bed8f498f27fb7a318f2b2f8b2c (patch) | |
tree | 3cd7ea346a98f3bf5dcf7f2b53a6e74193de54a4 | |
parent | 165352a2d163537afb01a835bccc7cd0a667410a (diff) | |
download | haskell-b57845c3d80f5bed8f498f27fb7a318f2b2f8b2c.tar.gz |
Clarify interruptible FFI wrt masking state
-rw-r--r-- | docs/users_guide/exts/ffi.rst | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/docs/users_guide/exts/ffi.rst b/docs/users_guide/exts/ffi.rst index e4a91944ef..847228089c 100644 --- a/docs/users_guide/exts/ffi.rst +++ b/docs/users_guide/exts/ffi.rst @@ -330,9 +330,10 @@ be annotated with ``interruptible`` instead of ``safe`` or ``unsafe``: :: "sleep" sleepBlock :: CUint -> IO CUint ``interruptible`` behaves exactly as ``safe``, except that when a -``throwTo`` is directed at a thread in an interruptible foreign call, an -OS-specific mechanism will be used to attempt to cause the foreign call -to return: +``throwTo`` is directed at a thread in an interruptible foreign call, +irrespective of the masking state, the exception is added to the blocked +exceptions queue of the target thread and an OS-specific mechanism will be +used to attempt to cause the foreign call to return: Unix systems The thread making the foreign call is sent a ``SIGPIPE`` signal @@ -348,7 +349,9 @@ Windows systems Once the system call is successfully interrupted, the surrounding code must return control out of the ``foreign import``, back into Haskell code, -so that the ``throwTo`` Haskell exception can be raised there. +so that any blocked exception can be raised if the masking state +of the thread allows it. Being under mask gives the Haskell code an opportunity +to detect and react to the interrupt error code from the c call. If the foreign code simply retries the system call directly without returning back to Haskell, then the intended effect of `interruptible` disappears |