Standard ML of New Jersey

The Signals structure


signature SIGNALS
structure Signals : SIGNALS

Signals provides an interface to signal system.


eqtype signal
datatype sig_action
  | HANDLER of (signal * int * unit cont) -> unit cont
val listSignals : unit -> signal list
val toString : signal -> string
val fromString : string -> signal option
val setHandler : (signal * sig_action) -> sig_action
val overrideHandler : (signal * sig_action) -> sig_action
val inqHandler : signal -> sig_action
datatype sigmask
  | MASK of signal list
val maskSignals : sigmask -> unit
val unmaskSignals : sigmask -> unit
val masked : unit -> sigmask
val pause : unit -> unit
val sigINT : signal
val sigALRM : signal
val sigTERM : signal
val sigGC : signal


eqtype signal
The type of signals (HUP, INT, QUIT, ...) deliverable to a process, plus ML-specific pseudo-signals such as "GC".

datatype sig_action

listSignals ()
Return a list of all signals recognized by the signal system. Since signal is an abstract type, one may wish to examine map toString (listSignals()) to see their names.

toString signal
Get the name of signal. Example: "HUP", "INT", "QUIT", etc.

fromString s
Convert a string to a signal, or return NONE if there is no such signal.

The structure UnixSignals defines several of these signal values, so that you need not suffer the indignity and insecurity of using fromString to look them up.

setHandler (signal, IGNORE)
setHandler (signal, DEFAULT)
setHandler (signal, HANDLER(f))
IGNORE tells the operating system to ignore signal and not to deliver it to the process.

DEFAULT tells the operating system to perform the default action for signal.

HANDLER(f) installs a handler for a signal. When signal is delivered to the process, the execution state of the current thread will be bundled up as a continuation k, then f(signal,n,k) will be called. The number n is the number of times signal has been signalled since the last time f was invoked for it. During the execution of f, all signals are held (not delivered). When f returns some continuation k', signals are re-enabled, and then k' is invoked.

overrideHandler (signal, handler)
If signal is not being ignored, then set the handler. This returns the previous handler (if IGNORE, then the current handler is still IGNORE).

inqHandler signal
Get the current action for signal.

datatype sigmask

maskSignals sigs
Mask the specified set of signals: signals that are not IGNORED will be delivered when unmasked. Calls to maskSignals nest on a per signal basis.

unmaskSignals sigs
Unmask the specified signals. The unmasking of a signal that is not masked has no effect.

masked ()
Return the set of masked signals; the value MASK[] means that no signals are masked.

pause ()
Sleep until the next signal; if called when signals are masked, then signals will still be masked when pause returns.

The interactive interrupt.

The interval timer signal.

Process termination.

Signalled by the runtime system (not by the operating system) immediately after each garbage collection.

[ Top | Parent | Contents | Index | Root ]

Last Modified October 28, 1997
Comments to
Copyright © 1998 Bell Labs, Lucent Technologies