#include <sicstus/sicstus.h> typedef void SP_SigFun (int sig, void *user_data); SP_SigFun SP_signal(int sig, SP_SigFun fun, void *user_data);
Installs a function
fun as a handler for the signal
It will be called with
user_data as arguments.
An extra, user defined value passed to the function.
SP_SIG_ERR if an error occurs error. On success,
some value different from
When the OS delivers a signal
sig for which
SP_signal(sig,func,…) has been called, SICStus will not call
func immediately. Instead the call to
func will be delayed
until it is safe for Prolog to do so, in much the same way that functions
SP_event() are handled.
Since the signal handling function
func will not be called
immediately upon delivery of the signal to the process it only makes
sense to use
SP_signal() to handle certain asynchronous signals
asynchronous signals handled specially by the OS, such as
are not suitable for handling via
SP_signal(). Note that the
development system installs a handler for ‘SIGINT’, and, under
Windows, ‘SIGBREAK’, to catch keyboard interrupts.
As of release 4.4,
library(timeout) no longer uses any signals.
func is called it may only call other (non SICStus) C code
SP_event(). Note that
func will be called in the main
fun is one of the special constants
SP_SIG_DFL, then one of two things happens:
sighas already been installed with
SP_signal(), then the SICStus OS-level signal handler is removed and replaced with, respectively,
SP_signal()does nothing and returns
A signal handler installed by a foreign resource should be
uninstalled in the deinit function for the foreign
resource. This is to prevent the handler in the foreign resource
from being called after the code of the foreign resource has been
unloaded (e.g. by
SP_signal() is not suitable for installing
signal handlers for synchronous signals like
SP_event(), Signal Handling.