14.  Signals  

      The procedures described in this section (except unix-kill, unix-list-signals, and unix-pause) are only defined if the local system supports reliable signals (either BSD-style or POSIX signals). In this case, the feature unix:reliable-signals is provided when the UNIX extension is loaded.

(unix-kill pid signal)

The UNIX kill() system call. pid is an integer; sig is either an integer (a signal number) or a symbol (a signal name). At least the following signal names are supported:

+----------------------------+
|       Signal names         |
+----------------------------+
|sigalrm   sigbus    sigfpe  |
|sighup    sigill    sigint  |
|sigkill   sigpipe   sigquit |
|sigsegv   sigterm           |
+----------------------------+

The list of signal names actually supported by the local system can be obtained by calling unix-list-signals (see below).

unix-kill returns the non-printing object.

(unix-list-signals)

This procedure returns a list of signal names (symbols) that are supported by the system.

(alarm seconds)

The UNIX alarm() function. seconds is a positive integer. unix-alarm returns the number of seconds remaining from the previously set alarm.

(unix-pause)

The UNIX pause() function. This procedure does not return.

(unix-signal sig action)
(unix-signal sig)

unix-signal defines or queries the action to be performed when a signal is delivered to the program. If an action argument is specified, this action is associated with the signal sig, and the previous action for this signal is returned. If no action is given (second form), unix-signal just returns the action currently associated with sig.

sig is the name of a signal (see unix-kill for a description). The action associated with sigbus, sigfpe, sigill, sigint, sigkill, sigsegv, and sigabrt (if supported) cannot be altered; either because UNIX does not permit this (sigkill), or because the signal can be generated as the result of an internal fatal error (sigbus etc.), or because it is used by the interpreter internally (sigsegv is used by the incremental garbage collector). The action associated with the interrupt signal can be controlled by redefining the standard Elk interrupt-handler (see the Elk reference manual for details).

action can be one of the following:

the symbol ignore
the specified signal is ignored
the symbol default
the default action for this signal is established
the symbol exit
cleanup and exit: if the signal is delivered, the interpreter's temporary files are removed, the finalization functions and static C++ destructors of dynamically loaded extensions are invoked, and exit() is called with an exit code of 1
a compound procedure
the procedure (signal handler) is invoked on delivery of the specified signal.

The procedure specified as a signal handler must accept one or more arguments. When the signal is delivered, the procedure is invoked with the signal name (a symbol) as an argument. Signal handlers must not return (i.e. they must either exit or call a continuation). If a signal handler returns, a message is displayed and the reset primitive is called.

The signal specified as an argument to unix-signal is added to (removed from) the signal mask maintained by the interpreter, i.e. calls to the disable-interrupts primitive block the signal from delivery.

unix-signal returns the previous (current) action for the specified signal (a procedure or ignore, default, or exit) or the symbol handler to indicate that the signal is handled internally by the interpreter.


Markup created by unroff 1.0,    September 24, 1996,    net@informatik.uni-bremen.de