Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- type Signal = CInt
- sigABRT :: CInt
- sigALRM :: CInt
- sigBUS :: CInt
- sigCHLD :: CInt
- sigCONT :: CInt
- sigFPE :: CInt
- sigHUP :: CInt
- sigILL :: CInt
- sigINT :: CInt
- sigKILL :: CInt
- sigPIPE :: CInt
- sigPOLL :: CInt
- sigPROF :: CInt
- sigQUIT :: CInt
- sigSEGV :: CInt
- sigSTOP :: CInt
- sigSYS :: CInt
- sigTERM :: CInt
- sigTRAP :: CInt
- sigTSTP :: CInt
- sigTTIN :: CInt
- sigTTOU :: CInt
- sigURG :: CInt
- sigUSR1 :: CInt
- sigUSR2 :: CInt
- sigVTALRM :: CInt
- sigXCPU :: CInt
- sigXFSZ :: CInt
- raiseSignal :: Signal -> IO ()
- signalProcess :: Signal -> ProcessID -> IO ()
- signalProcessGroup :: Signal -> ProcessGroupID -> IO ()
- installHandler :: Signal -> Handler -> Maybe SignalSet -> IO Handler
- data Handler
- = Default
- | Ignore
- | Catch (IO ())
- | CatchOnce (IO ())
- | CatchInfo (SignalInfo -> IO ())
- | CatchInfoOnce (SignalInfo -> IO ())
- data SignalInfo = SignalInfo {}
- data SignalSpecificInfo
- data SignalSet
- emptySignalSet :: SignalSet
- fullSignalSet :: SignalSet
- reservedSignals :: SignalSet
- addSignal :: Signal -> SignalSet -> SignalSet
- deleteSignal :: Signal -> SignalSet -> SignalSet
- inSignalSet :: Signal -> SignalSet -> Bool
- getSignalMask :: IO SignalSet
- setSignalMask :: SignalSet -> IO ()
- blockSignals :: SignalSet -> IO ()
- unblockSignals :: SignalSet -> IO ()
- scheduleAlarm :: Int -> IO Int
- getPendingSignals :: IO SignalSet
- awaitSignal :: Maybe SignalSet -> IO ()
- setStoppedChildFlag :: Bool -> IO Bool
- queryStoppedChildFlag :: IO Bool
Signals
Sending signals
raiseSignal :: Signal -> IO () #
raiseSignal int
calls kill
to signal the current process
with interrupt signal int
.
signalProcess :: Signal -> ProcessID -> IO () #
signalProcess int pid
calls kill
to signal process pid
with interrupt signal int
.
signalProcessGroup :: Signal -> ProcessGroupID -> IO () #
signalProcessGroup int pgid
calls kill
to signal
all processes in group pgid
with interrupt signal int
.
Handling signals
installHandler int handler iset
calls sigaction
to install an
interrupt handler for signal int
. If handler
is Default
,
SIG_DFL
is installed; if handler
is Ignore
, SIG_IGN
is
installed; if handler
is Catch action
, a handler is installed
which will invoke action
in a new thread when (or shortly after) the
signal is received.
If iset
is Just s
, then the sa_mask
of the sigaction
structure
is set to s
; otherwise it is cleared. The previously installed
signal handler for int
is returned
The actions to perform when a signal is received.
Default | |
Ignore | |
Catch (IO ()) | |
CatchOnce (IO ()) | |
CatchInfo (SignalInfo -> IO ()) | Since: unix-2.7.0.0 |
CatchInfoOnce (SignalInfo -> IO ()) | Since: unix-2.7.0.0 |
data SignalInfo #
Information about a received signal (derived from siginfo_t
).
Since: unix-2.7.0.0
data SignalSpecificInfo #
Information specific to a particular type of signal
(derived from siginfo_t
).
Since: unix-2.7.0.0
Signal sets
deleteSignal :: Signal -> SignalSet -> SignalSet infixr 9 #
inSignalSet :: Signal -> SignalSet -> Bool #
Signal mask
getSignalMask :: IO SignalSet #
getSignalMask
calls sigprocmask
to determine the
set of interrupts which are currently being blocked.
setSignalMask :: SignalSet -> IO () #
setSignalMask mask
calls sigprocmask
with
SIG_SETMASK
to block all interrupts in mask
.
blockSignals :: SignalSet -> IO () #
blockSignals mask
calls sigprocmask
with
SIG_BLOCK
to add all interrupts in mask
to the
set of blocked interrupts.
unblockSignals :: SignalSet -> IO () #
unblockSignals mask
calls sigprocmask
with
SIG_UNBLOCK
to remove all interrupts in mask
from the
set of blocked interrupts.
Alarm timer
scheduleAlarm :: Int -> IO Int #
scheduleAlarm i
calls alarm
to schedule a real time
alarm at least i
seconds in the future.
Waiting for signals
getPendingSignals :: IO SignalSet #
getPendingSignals
calls sigpending
to obtain
the set of interrupts which have been received but are currently blocked.
awaitSignal :: Maybe SignalSet -> IO () #
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 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.
NOCLDSTOP
setStoppedChildFlag :: Bool -> IO Bool #
Tells the system whether or not to set the SA_NOCLDSTOP
flag when
installing new signal handlers.
queryStoppedChildFlag :: IO Bool #
Queries the current state of the stopped child flag.