All Manuals > LispWorks® User Guide and Reference Manual > 47 The SYSTEM Package

set-signal-handler Function

Summary

Installs or removes a handler for a POSIX signal (non-Windows platforms).

Package

system

Signature

set-signal-handler signum handler

Arguments
signum
A POSIX signal number.
handler
A function or nil.
Description

The function set-signal-handler configures a POSIX signal handler.

If handler is non-nil, then handler will be called when the POSIX signal signum occurs.

If handler is nil, any handler for signum is removed.

handler should be defined to take an &rest argument, and ignore it. There are no restrictions on handler other than those applying to any asynchronous function call, and that it may be called in any thread. In particular there is no need to handle the signal immediately.

The configuration established by set-signal-handler is not persistent over image saving (or application delivery), so it should be called each time the image (or application) is started.

Notes

The currently defined signal handlers are shown in the output of the bug report template which can generated via the :bug-form listener command. For example, there is a SIGINT handler which calls break. You should consult Lisp Support before overwriting existing signal handlers.

LispWorks initially has no SIGHUP handler. SIGHUP will kill a LispWorks process which does not have a SIGHUP handler installed. When the LispWorks IDE starts up, a SIGHUP handler (which attempts to release locks in the environment) is installed. However if you need a SIGHUP handler in a server application, for example, you should install one using set-signal-handler.

Examples
(defun my-hup-handler (&rest x)
  (declare (ignorable x))
  (cerror "Continue"
   "Got a HUP signal"))
(sys:set-signal-handler 1 'my-hup-handler)

Note that the LispWorks IDE overwrites a SIGHUP handler, so you would need to reinstall it after GUI startup.


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:31:02