on_signal(Signal, Current, Current)
.
The action description is an atom denoting the name of the predicate that will be called if Signal arrives. on_signal/3 is a meta-predicate, which implies that <Module>:<Name> refers to <Name>/1 in module <Module>. The handler is called with a single argument: the name of the signal as an atom. The Prolog names for signals are explained below.
Four names have special meaning. throw
implies Prolog
will map the signal onto a Prolog exception as described in section
4.10,
ignore
causes Prolog to ignore the signal entirely,
debug
specifies the debug interrupt prompt that is
initially bound to SIGINT
(Control-C) and default
resets the handler to the settings active before SWI-Prolog manipulated
the handler.
Signals bound to a foreign function through PL_signal()
are reported using the term ’$foreign_function'(Address)
.
After receiving a signal mapped to throw
, the exception
raised has the following structure:
error(signal(<SigName>, <SigNum>), <Context>)
The signal names are defined by the POSIX standard as symbols of the
form SIG
<SIGNAME>. The Prolog name for a
signal is the lowercase version of <SIGNAME>. The
predicate current_signal/3
may be used to map between names and signals.
Initially, the following signals are handled unless the command line option --no-signals is specified:
- int
- Prompts the user, allowing to inspect the current state of the process and start the tracer.
- usr2
- Bound to an empty signal handler used to make blocking system calls return. This allows thread_signal/2 to interrupt threads blocked in a system call. See also prolog_alert_signal/2.
- pipe
- Ignored.
- hup, term, abrt, quit
- Causes normal Prolog cleanup (e.g., at_halt/1) before terminating the process with the same signal.
- segv, ill, bus, sys
- Dumps the C and Prolog stacks and runs cleanup before terminating the process with the same signal.
- fpe, alrm, xcpu, xfsz, vtalrm
- Throw a Prolog exception (see above).