The Quipper System

Safe HaskellNone

Libraries.PortableSignals

Description

This module provides a thin portability layer for handling user interrupts.

The reason is that in the standard Haskell library, this functionality is only available in operating system specific modules, namely System.Posix.Signals (for POSIX systems, including Linux) and GHC.ConsoleHandler (for Windows).

Note that despite this compatibility layer, there are some operating system specific quirks:

  • In Windows, console events (such as Control-C) can only be received by an application running in a Windows console. Certain environments that look like consoles do not support console events, such as xterm and rxvt windows, and Cygwin shells with CYGWIN=tty set.
  • In Windows, setting a handler for any one signal automatically overrides the handlers for all signals (effectively ignoring them). Also, if the Default or Ignore handler is specified, it applies to all signals. We do not currently provide a way to specify handlers for multiple signals.

Synopsis

Documentation

data Signal Source #

A data type for signals. This can be extended as needed.

Constructors

Interrupt

Control-C event.

Close

TERM signal (POSIX) or Close event (Windows).

data Handler Source #

A data type for handlers.

Constructors

Default

Default action.

Ignore

Ignore the signal.

Catch (IO ())

Handle the signal in a new thread when the signal is received.

CatchOnce (IO ())

Like Catch, but only handle the first such signal.

installHandler :: Signal -> Handler -> IO Handler Source #

Install a handler for the given signal. The old handler is returned.

with_handler :: Signal -> Handler -> IO a -> IO a Source #

Run a block of code with a given signal handler. The previous handler is restored when the block terminates.