中断也是GHC中的异步异常吗?

Is interruption also an asynchronous exception in GHC?

在尝试了解 GHC 程序如何处理信号和异常时,我发现了一个关于 "fixing" the bracket.

的有趣但不确定的讨论

我很难理解为什么括号已经 masks asynchronous exceptions.

时还需要更改

在我看来,中断(如 POSIX 信号)不是异步异常,或者我在当前长期实施中遗漏了一些细节:

bracket before after thing =
  mask $ \restore -> do
    a <- before
    r <- restore (thing a) `onException` after a
    _ <- after a -- can be interrupted??
    return r

根据我的理解,必须评估 after a 以提供 IO 将由 mask 范围内的 IO monad 强制执行的操作。

编辑:在这个话题上,为什么 after 不是 运行 两次以防异常?

mask 某种 防止引发异步中断。

Asynchronous exceptions may still be received while in the masked state if the masked thread blocks in certain ways

有一个不同的函数,uninterruptibleMask,它可以完全阻止异步异常。

A POSIX 中断信号默认会在主线程中引发 AsyncException。如果我理解正确,我认为这与您的问题无关。当人们说 "interruptable" 时,他们并不是特指 POSIX 中断信号;他们的意思是如果一个动作没有被uninterruptibleMask屏蔽,那么它就是"interruptable",因此可以从任何来源接收任何异步异常。