When multiple traps are present in a system, we begin to have a bookkeeping problem. How are they named? How does one disable, enable, or delete them?
Guile’s answer to this is to keep an implicit per-thread trap state. The trap state object is not exposed to the user; rather, API that works on trap states fetches the current trap state from the dynamic environment.
Traps are identified by integers. A trap can be enabled, disabled, or removed, and can have an associated user-visible name.
These procedures have their own module:
(use-modules (system vm trap-state))
Add a trap to the current trap state, associating the given name with it. Returns a fresh trap identifier (an integer).
Note that usually the more specific functions detailed in High-Level Traps are used in preference to this one.
List the current set of traps, both enabled and disabled. Returns a list of integers.
Returns the name associated with trap idx, or #f
if there
is no such trap.
Returns #t
if trap idx is present and enabled, or #f
otherwise.
Enables trap idx.
Disables trap idx.
Removes trap idx, disabling it first, if necessary.