Before deciding to deal with signals in your application, please consider the following:
On MS-Windows, the signal interface is severely limited. Different Unix brands support different sets of signals, and the relation between signal name and number may vary. Currently, the system only supports signals numbered 1 to 3269TBD: the system should support the Unix realtime signals. Installing a signal outside the limited set of supported signals in MS-Windows crashes the application.
Immediately delivered signals (see below) are unsafe. This implies that foreign functions called from a handler cannot safely use the SWI-Prolog API and cannot use C longjmp(). Handlers defined as
throware unsafe. Handlers defined to call a predicate are safe. Note that the predicate can call throw/1, but the delivery is delayed until Prolog is in a safe state.
The C-interface described in section 11.4.13 provides the option
PL_SIGSYNCto select either safe synchronous or unsafe asynchronous delivery.
- Time of delivery
throwor a foreign handler, signals are delivered immediately (as defined by the OS). When using a Prolog predicate, delivery is delayed to a safe moment. Blocking system calls or foreign loops may cause long delays. Foreign code can improve on that by calling PL_handle_signals().
Signals are blocked when the garbage collector is active.