[GHC] #4504: "awaitSignal Nothing" does not block thread with -threaded
GHC
cvs-ghc at haskell.org
Wed Dec 8 11:49:57 CET 2010
#4504: "awaitSignal Nothing" does not block thread with -threaded
---------------------------------+------------------------------------------
Reporter: adept | Owner: adept
Type: bug | Status: patch
Priority: normal | Milestone: 7.2.1
Component: Runtime System | Version: 7.0.1
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Incorrect result at runtime
---------------------------------+------------------------------------------
Comment(by adept):
Please note that {{{awaitSignals (Just reservedSignals)}}} would use just
{{{reservedSignals}}} as signal mask, instead of adding them to the
current process mask.
Let's look at the problem from this perspective: suppose that we set up a
bunch of signal handlers and now we want to block until the signal
arrives. Right now documentation says to use {{{awaitSignal Nothing}}}.
Unfortunately, {{{awaitSignal Nothing}}} is completely useless with
"-threaded".
So, in order to write robust code that would work either way we would have
to do something like this (and add this example to the documentation of
"awaitSignal"):
{{{
{-# LANGUAGE CPP #-}
import Control.Concurrent (rtsSupportsBoundThreads)
import System.Posix.Signals
blockTillSignal = do
sigset <- getSignalMask
let sigset' =
case rtsSupportsBoundThreads of
False -> sigset
True -> unionSignalSets sigset reservedSignals -- i'm making
this up, no function like this right now.
awaitSignal sigset'
}}}
Now, as you can see, this has large overlap with {{{awaitSignal}}} code. I
think that this is a job for the library to hide away exactly this sort of
complexity.
I might have a case of tunnel vision, but it seems like {{{awaitSignal
Nothing}}} has a very limited use right now, unless one writes the code
and is 100% sure that it would be used without "-threaded", which is
simply not right.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4504#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list