<div dir="ltr"><div>The definition of threadWait is:</div><div><pre style="color:rgb(0,0,0)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">threadWait</span> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)">::</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Internal.html#Event" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-type" style="color:rgb(95,95,175)">Event</span></a> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)">-></span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/System.Posix.Types.html#Fd" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-type" style="color:rgb(95,95,175)">Fd</span></a> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)">-></span> <span class="gmail-hs-identifier gmail-hs-type" style="color:rgb(95,95,175)">IO</span> <span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span>
<a name="line-115"></a><a name="threadWait"></a><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#threadWait" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">threadWait</span></a> <a name="local-6989586621679365266"></a><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365266" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">evt</span></a> <a name="local-6989586621679365267"></a><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365267" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">fd</span></a> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)">=</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.IO.html#mask_" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">mask_</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Base.html#%24" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">$</span></a> <span class="gmail-hs-keyword" style="color:rgb(175,0,95)">do</span>
<a name="line-116"></a> <a name="local-6989586621679365268"></a><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365268" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">m</span></a> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)"><-</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.MVar.html#newEmptyMVar" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">newEmptyMVar</span></a>
<a name="line-117"></a> <a name="local-6989586621679365269"></a><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365269" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">mgr</span></a> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)"><-</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#getSystemEventManager_" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">getSystemEventManager_</span></a>
<a name="line-118"></a> <a name="local-6989586621679365271"></a><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365271" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">reg</span></a> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)"><-</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Manager.html#registerFd" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">registerFd</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365269" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">mgr</span></a> <span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><span class="gmail-hs-glyph" style="color:rgb(220,50,47)">\</span><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">_</span> <a name="local-6989586621679365270"></a><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365270" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">e</span></a> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)">-></span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.MVar.html#putMVar" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">putMVar</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365268" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">m</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365270" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">e</span></a><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365267" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">fd</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365266" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">evt</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Internal.html#OneShot" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">M.OneShot</span></a>
<a name="line-119"></a> <a name="local-6989586621679365272"></a><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365272" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier" style="color:rgb(7,54,66)">evt'</span></a> <span class="gmail-hs-glyph" style="color:rgb(220,50,47)"><-</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.MVar.html#takeMVar" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">takeMVar</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365268" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">m</span></a> <span class="gmail-hs-special" style="color:rgb(220,50,47)">`</span><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.IO.html#onException" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">onException</span></a><span class="gmail-hs-special" style="color:rgb(220,50,47)">`</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Manager.html#unregisterFd_" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">unregisterFd_</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365269" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">mgr</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365271" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">reg</span></a>
<a name="line-120"></a> <span class="gmail-hs-keyword" style="color:rgb(175,0,95)">if</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Thread.html#local-6989586621679365272" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">evt'</span></a> <span class="gmail-hs-special" style="color:rgb(220,50,47)">`</span><a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Internal.html#eventIs" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">eventIs</span></a><span class="gmail-hs-special" style="color:rgb(220,50,47)">`</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Event.Internal.html#evtClose" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">evtClose</span></a>
<a name="line-121"></a> <span class="gmail-hs-keyword" style="color:rgb(175,0,95)">then</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.IO.Exception.html#ioError" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">ioError</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Base.html#%24" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-operator gmail-hs-var" style="color:rgb(211,54,130)">$</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/Foreign.C.Error.html#errnoToIOError" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">errnoToIOError</span></a> <span class="gmail-hs-string" style="color:rgb(203,75,22)">"threadWait"</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/Foreign.C.Error.html#eBADF" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">eBADF</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Maybe.html#Nothing" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">Nothing</span></a> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Maybe.html#Nothing" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">Nothing</span></a>
<a name="line-122"></a> <span class="gmail-hs-keyword" style="color:rgb(175,0,95)">else</span> <a href="http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Base.html#return" class="gmail-" style="text-decoration-line:none;border-bottom:1px solid rgb(238,232,213)"><span class="gmail-hs-identifier gmail-hs-var" style="color:rgb(7,54,66)">return</span></a> <span class="gmail-hs-special" style="color:rgb(220,50,47)">(</span><span class="gmail-hs-special" style="color:rgb(220,50,47)">)</span>
</pre>Although the entire function has asynchronous exceptions masked, the call to takeMVar uses onException to deal with the possibility of an exception. According to the docs in Control.Concurrent, takeMVar can throw exceptions. But my understand (which may be wrong) is that the only exception this could throw would be something like BlockedIndefinitelyOnMVar, which I don't believe can happen here.</div><div><br></div><div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">-Andrew Thaddeus Martin</div></div></div>