diff options
author | Dmitry Astapov <dastapov@gmail.com> | 2010-12-08 18:38:49 +0000 |
---|---|---|
committer | Dmitry Astapov <dastapov@gmail.com> | 2010-12-08 18:38:49 +0000 |
commit | 04ba2812edb81fa07b05295b8487bfd1ff399f16 (patch) | |
tree | 95566ea0fd3cf1ae40f7da335fa7c59d2dd57584 /System | |
parent | 298d9fd83318c208dc6facf419c03926d65613e0 (diff) |
Clarify behavior of "awaitSignal Nothing", export SignalSet that includes all signals reserved by RTS (#4504)
Diffstat (limited to 'System')
-rw-r--r-- | System/Posix/Signals.hsc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/System/Posix/Signals.hsc b/System/Posix/Signals.hsc index 92f0e38..e156e5b 100644 --- a/System/Posix/Signals.hsc +++ b/System/Posix/Signals.hsc @@ -71,7 +71,7 @@ module System.Posix.Signals ( -- * Signal sets SignalSet, - emptySignalSet, fullSignalSet, + emptySignalSet, fullSignalSet, reservedSignals, addSignal, deleteSignal, inSignalSet, -- * The process signal mask @@ -495,6 +495,13 @@ fullSignalSet = unsafePerformIO $ do throwErrnoIfMinus1_ "fullSignalSet" (withForeignPtr fp $ c_sigfillset) return (SignalSet fp) +-- | A set of signals reserved for use by the implementation. In GHC, this will normally +-- include either `sigVTALRM` or `sigALRM`. +reservedSignals :: SignalSet +reservedSignals = addSignal rtsTimerSignal emptySignalSet + +foreign import ccall rtsTimerSignal :: CInt + infixr `addSignal`, `deleteSignal` addSignal :: Signal -> SignalSet -> SignalSet addSignal sig (SignalSet fp1) = unsafePerformIO $ do @@ -565,9 +572,15 @@ getPendingSignals = do -- | @awaitSignal iset@ suspends execution until an interrupt is received. -- If @iset@ is @Just s@, @awaitSignal@ calls @sigsuspend@, installing -- @s@ as the new signal mask before suspending execution; otherwise, it --- calls @pause@. @awaitSignal@ returns on receipt of a signal. If you --- have installed any signal handlers with @installHandler@, it may be --- wise to call @yield@ directly after @awaitSignal@ to ensure that the +-- calls @sigsuspend@ with current signal mask. Note that RTS +-- scheduler signal (either 'virtualTimerExpired' or 'realTimeAlarm') +-- could cause premature termination of this call. It might be necessary to block that +-- signal before invocation of @awaitSignal@ with 'blockSignals' 'reservedSignals'. +-- +-- @awaitSignal@ returns when signal was received and processed by a +-- signal handler, or if the signal could not be caught. If you have +-- installed any signal handlers with @installHandler@, it may be wise +-- to call @yield@ directly after @awaitSignal@ to ensure that the -- signal handler runs as promptly as possible. awaitSignal :: Maybe SignalSet -> IO () awaitSignal maybe_sigset = do |