|
| System.Posix.Signals | | Portability | non-portable (requires POSIX) | | Stability | provisional | | Maintainer | libraries@haskell.org |
|
|
|
|
|
| Description |
| POSIX signal support
|
|
| Synopsis |
|
|
|
|
| The Signal type
|
|
| Signal |
|
| Specific signals
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Sending signals
|
|
|
| raiseSignal int calls kill to signal the current process
with interrupt signal int.
|
|
|
| signalProcess int pid calls kill to signal process pid
with interrupt signal int.
|
|
|
| signalProcessGroup int pgid calls kill to signal
all processes in group pgid with interrupt signal int.
|
|
| Handling signals
|
|
|
registers a signal handler function to be executed when the specified
signal is received. Any number of signal handler functions may be attached
to a signal using addSignalHandler.
When a signal is received, each handler registered for the signal
is forked in a new thread.
While there are any signal handlers registered for a given signal,
the default behaviour of that signal is disabled. The default
behaviour for some signals is to terminate or stop the process
(consult the POSIX documentation or the signal man-page for a
list), while for others the default behaviour is to ignore the
signal. To explicitly ignore a signal for which the default
behaviour is to terminate the process, use
addSignalHandler sig (const (return ()))
|
|
|
| like addSignalHandler except the signal handler is run at most once,
the next time the signal is received.
|
|
|
| remove the specified signal handler. Returns True if the
signal handler was found and successfully removed, or False if
the specified signal handler could not be found.
|
|
|
|
|
| Information about a received signal (derived from siginfo_t).
| | Constructors | |
|
|
| data SignalSpecificInfo | Source |
|
| Information specific to a particular type of signal
(derived from siginfo_t).
| | Constructors | | NoSignalSpecificInfo | | | SigChldInfo | | |
|
|
|
| (old, deprecated) Handling signals
|
|
|
| Constructors | | Default | | | Ignore | | | Catch (IO ()) | | | CatchOnce (IO ()) | |
|
|
|
|
| :: Signal | | | -> Handler | | | -> Maybe SignalSet | other signals to block
| | -> IO Handler | old handler
| | 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
|
|
|
| Signal sets
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| The process signal mask
|
|
|
| getSignalMask calls sigprocmask to determine the
set of interrupts which are currently being blocked.
|
|
|
| setSignalMask mask calls sigprocmask with
SIG_SETMASK to block all interrupts in mask.
|
|
|
blockSignals mask calls sigprocmask with
SIG_BLOCK to add all interrupts in mask to the
set of blocked interrupts.
Note: this is not particularly useful in Haskell, signal handlers
are not atomic as they are in C. A signal handler may have already
been created as a thread, but not run yet, and blockSignals will
not prevent it from running. You should consider other methods for
synchronising with signal handlers, such as MVars or STM.
|
|
|
| unblockSignals mask calls sigprocmask with
SIG_UNBLOCK to remove all interrupts in mask from the
set of blocked interrupts.
|
|
| The alarm timer
|
|
|
| scheduleAlarm i calls alarm to schedule a real time
alarm at least i seconds in the future.
|
|
| Waiting for signals
|
|
|
| getPendingSignals calls sigpending to obtain
the set of interrupts which have been received but are currently blocked.
|
|
|
| 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 handleSignal, for example, it may be
wise to call yield directly after awaitSignal to ensure that the
signal handler runs as promptly as possible.
|
|
| The NOCLDSTOP flag
|
|
| setStoppedChildFlag :: Bool -> IO Bool | Source |
|
| Tells the system whether or not to set the SA_NOCLDSTOP flag when
installing new signal handlers.
|
|
|
| Queries the current state of the stopped child flag.
|
|
| Produced by Haddock version 0.9 |