HORIZON HASKELLDocslts/ghc-10.0.x04404a62026-10-19Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 04404a6 · 2026-10-19

Moduleunix-2.8.8.0Haskell2010

System.Posix.Signals

POSIX signal support

Contents
  1. The Signal type
  2. Specific signals
  3. Sending signals
  4. Handling signals
  5. Signal sets
  6. The process signal mask
  7. The alarm timer
  8. Waiting for signals
  9. The NOCLDSTOP flag
Synopsis
  • Packageunix-2.8.8.0
  • Exports81
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceSignals.hsc

The Signal type

Specific signals

Sending signals

valueraiseSignal :: Signal -> IO ()

raiseSignal int calls kill to signal the current process with interrupt signal int.

Handling signals

datadata Handler

The actions to perform when a signal is received.

Constructors

  • Default

    Sets the disposition of the signal to SIG_DFL, which means we want the default action associated with the signal. For example, the default action for SIGTERM (and various other signals) is to terminate the process.

  • Ignore

    Set the disposition of the signal to SIG_IGN, which means we want to ignore the signal. Ignored signals will not be delivered to the process, and if also blocked will not be added to the pending set for later delivery (if/when unblocked). Some signals (e.g. SIGSTOP and SIGKILL) cannot be caught or ignored. not yet: | Hold

  • Catch (IO ())

    signal handler is not reset

  • CatchOnce (IO ())

    signal handler is automatically reset (via SA_RESETHAND)

  • CatchInfo (SignalInfo -> IO ())
  • CatchInfoOnce (SignalInfo -> IO ())
valueinstallHandler
  1. :: Signal
  2. -> Handler
  3. -> Maybe SignalSet

    other signals to block

  4. -> 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

valueblockSignals :: SignalSet -> IO ()

blockSignals mask calls sigprocmask with SIG_BLOCK to add all interrupts in mask to the set of blocked interrupts.

unblockSignals mask calls sigprocmask with SIG_UNBLOCK to remove all interrupts in mask from the set of blocked interrupts.

The alarm timer

Waiting for signals

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.

The NOCLDSTOP flag