If you find that this library lacks some feature you need, or you have
a suggestion for improving it, please don’t hesitate to
get in touch with me!
This library provides a means of sending and receiving Unix signals to
Be warned that attempting to receive certain signals used by the
Racket runtime is dangerous, as the code here will conflict with the
code in Racket itself.
2 What to require
All the functionality below can be accessed with a single
This library represents signal names as symbols all in upper-case;
for example, 'SIGUSR1 and 'SIGKILL.
2.1 Waiting for a signal
To receive Unix signals using this library, call
capture-signal! once for each signal of interest, and then
use next-signal-evt or read-signal. Use
ignore-signal! and release-signal! to ignore a
signal (SIG_IGN) or to install the default
signal-handler (SIG_DFL), respectively.
Calls to capture-signal! and friends have global effect
within the Racket process. Likewise, use of next-signal-evt
and read-signal have global side-effects on the state of the
Installs a signal handler for the given signal. When the given signal
is received by the process, its signal number will be returned by uses
Causes the given signal to be ignored (SIG_IGN) by the process.
Installs the default handler (SIG_DFL) for the given signal.
becomes ready when a signal previously registered with
is received, at which point it returns the
number of the received signal as its synchronization result by
yielding the result of a call to read-signal
Blocks until a signal previously
registered with capture-signal!
is received. Returns the
number of the received signal. Signals are buffered internally using
the self-pipe trick
are therefore delivered in order of receipt.
2.2 Sending a signal
This library provides getpid from racket/os
Calls kill(2) to deliver the given signal to the
given process ID. All special cases for pid from the
kill(2) manpage apply.
2.3 Mapping between signal names and signal numbers
Returns a fixnum if the symbol name is defined, or #f if not.
a symbol naming the given signal number, if one is defined, or
#f if not. Note that in cases where multiple C identifiers
map to a given signal number, an arbitrary choice among the
possibilities is returned.