Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the trivial-signal Reference Manual, version 0.1.0, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 15:21:03 2020 GMT+0.
• Introduction | What trivial-signal is all about | |
• Systems | The systems documentation | |
• Modules | The modules documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
Trivial-signal is a Common Lisp UNIX signal handling library.
News : now equipped with nested signal handling capability & multithreads! See `Threading Policy`` below. (Masataro Asai)
News : Maintainer has changed. Thanks Fukamachi! (Masataro Asai)
News : It now uses CFFI-grovel to obtain the signal numbers. It now recognizes much more signals e.g. SIGRTMIN. I hope it works even on SPARK !
~TODO~ : exit handlers (with atexit
) --> Consider exit-hooks.
Requirements :
Installation :
cd ~/common-lisp/
git clone https://github.com/guicho2.71828/trivial-signal.git
(ql:quickload :trivial-signal)
(use-package :trivial-signal)
(defun exit-on-signal (signo)
(format *error-output* "~&received ~A~%" (signal-name signo))
(sb-ext:exit :code 1 :abort t))
(setf (signal-handler :term) #'exit-on-signal) ;; :term can also be :sigterm or 15
(loop (sleep 3))
;; now run `kill -15 $PID` on the terminal to run `exit-on-signal`
Above example shows the usage of toplevel handlers. Toplevel handlers are system wide and (in most cases) static.
The next important usage of trivial-signal is
to establish handlers dynamically by signal-handler-bind
.
The scope of this kind of signal handlers are thread-local.
When the main process receives a signal,
handlers are called in the same way as in handler-bind
: the
top handler in the innermost signal-handler-bind
is called first.
(use-package :trivial-signal)
(tagbody
(signal-handler-bind ((15 (lambda (c) (print :first)))
(15 (lambda (c) (print :escaping) (go :escape)))
;; mixing different handlers is ok
(2 (lambda (c) (print :escaping) (go :escape)))
;; once the signal is handled, remaining handlers are not called
(15 (lambda (c) (print :this-should-not-be-called))))
(loop (sleep 3))) ;; now send signal 15 from the terminal
:escape
(print :success!))
(tagbody
;; nested handlers are called from the most recently established ones.
;; If the handler declines, the next innermost one is called.
(signal-handler-bind ((15 (lambda (c) (print :this-should-not-be-called))))
(signal-handler-bind ((15 (lambda (c) (print :escaping) (go :escape))))
(signal-handler-bind ((15 (lambda (c) (print :most-recent))))
(loop (sleep 3)))))
:escape
(print :success!))
If all these thread-local handlers decline, then the toplevel handlers are called.
If that declines again, then a common-lisp condition unix-signal
is
signaled in that context.
Signals are handled by C-level posix signal(8)
API
with which we set a low-level handler through CFFI.
Note that, depending on the lisp implementation, some signals may not be captured. This is related to the implementations' internal, which may use signals internally for their own sake (such as thread manipulation).
At least I checked the following signals work:
To see which signals works on your environment, see TESTING.org
The C-level signal handlers call a lisp function, which interrupts each
thread who has thread-local signal handlers established by
signal-handler-bind
.
Signals directly sent to each thread might not be captured by trivial-signal
.
The behavior is currently undefined.
Our advise is that they should be sent to the main process.
This is again related to the internal behavior of the implementations. For example, on SBCL, signals sent to the main process are not distributed to each thread. However, CCL seems to distribute the signals.
Signals can be either specified by its number or by its name.
In trivial-signal
, the name can be specified with keywords.
Below examples should be sufficient :
+sigterm+
is bound to 15)+sigint+
is bound to 2 )+sigxcpu+
is bound to 24)Note that the signal number actually depends on the OS you are using.
These numbers are obtained by cffi-grovel
, therefore OS level
compatibility is now fixed.
This returns the name of SIGNO
as a keyword.
(signal-name 15)
;=> :TERM
This returns the number of SIGNAME
as an integer.
(signal-number :term)
;=> 15
This executes FORMS
in an environment where signal handler bindings are in effect.
(signal-handler-bind ((:term (lambda (signo)
(declare (ignore signo))
(sb-ext:exit :abort t)))
(:int (lambda (signo)
(princ (signal-name signo) *error-output*))))
;; do something.
)
Run FN in a dynamic environment where the signal handler bindings are
in effect. new-signal-handlers
is a cons tree of ((signo handler ...) ...).
This is rather an internal function which signal-handler-bind expands into.
Use this function when you want to dynamically alter the signal to be captured.
Note that, trivial-signal only considers the first appearance of (signo handlers...) with the matching signo in the same layer. For example,
(call-signal-handler-bind
`((,*signo* ,(lambda (c) (lprint :first))
,(lambda (c) (lprint :escaping) (go :escape))
,(lambda (c) (lprint :this-should-not-be-called))))
(lambda () ...))
is okay but
(call-signal-handler-bind
`((,*signo* ,(lambda (c) (lprint :first)))
(,*signo* ,(lambda (c) (lprint :escaping) (go :escape)))
(,*signo* ,(lambda (c) (lprint :this-should-not-be-called))))
(lambda () ... ))
is incorrect (the 2nd and 3rd handlers are ignored).
If you want to do it, wrap the main code in the (lambda () ...)
with another call-signal-handler-bind.
(Also, the macro signal-handler-bind
automatically solve this.)
(deprecated)
This executes FORMS
in an environment where a signal handler FN
for a signal SIGNAL
is in effect.
(with-signal-handler :term (lambda (signo)
(declare (ignore signo))
(sb-ext:exit :abort t))
;; do something.
)
Toplevel handlers are system wide, global handlers that capture the signals
sent to the main process.
The functionality of the toplevel signal handlers are analogous to *debugger-hook*
.
When the lisp process receives a signal,
it is handled by these toplevel handlers
unless some nested signal handlers (described later) handles it.
(use-package :trivial-signal)
(defun exit-on-signal (signo)
(format *error-output* "~&received ~A~%" (signal-name signo))
(sb-ext:exit :code 1 :abort t))
(signal-handler :term) ;=> NIL
(setf (signal-handler :term) #'exit-on-signal)
;=> #<FUNCTION (LAMBDA (SIGNO)) {1005764E3B}>
(signal-handler :term)
;=> #<FUNCTION (LAMBDA (SIGNO)) {1005764E3B}>
; T
;; Removing a signal handler.
(setf (signal-handler :term) nil) ; or: (remove-signal-handler :term) (deprecated)
;=> T
;; Clearing all signal handlers.
(remove-all-signal-handlers)
This returns a signal handler for a signal SIGNAL
.
SIGNAL
can be either a keyword or an integer.
(signal-handler :term)
(signal-handler 15)
(signal-handler +sigterm+)
This sets a signal handler FN
for a signal SIGNAL
.
FN
must be a function or a symbol of a function name, which takes one
argument as a signal number.
Otherwise FN
should be NIL
, indicating the handler should be removed.
(setf (signal-handler :term)
#'(lambda (signo)
(princ (signal-name signo) *error-output*)))
(deprecated) This removes a signal handler from a signal SIGNAL
.
This clears all signal handlers.
Trivial-signal is free and unencumbered software released into the public domain.
Next: Modules, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The trivial-signal system |
Eitaro Fukamachi
Public Domain
Unix signal handling library.
# trivial-signal [](https://travis-ci.org/guicho271828/trivial-signal)
Trivial-signal is a Common Lisp UNIX signal handling library.
**News** : now equipped with nested signal handling capability &
multithreads! See ‘Threading Policy“ below. (Masataro Asai)
**News** : Maintainer has changed. Thanks Fukamachi! (Masataro Asai)
**News** : It now uses CFFI-grovel to obtain the signal numbers. It now
recognizes much more signals e.g. SIGRTMIN. I hope it works even on SPARK !
~**TODO**~ : exit handlers (with ‘atexit‘) –> Consider [exit-hooks](https://github.com/ailisp/exit-hooks).
**Requirements** :
* [CFFI](http://common-lisp.net/project/cffi/)
* [Bordeaux-threads](http://trac.common-lisp.net/bordeaux-threads/wiki/ApiDocumentation)
**Installation** :
“‘
cd ~/common-lisp/
git clone https://github.com/guicho2.71828/trivial-signal.git
“‘
“‘common-lisp
(ql:quickload :trivial-signal)
“‘
## Usage : Toplevel Handlers
“‘common-lisp
(use-package :trivial-signal)
(defun exit-on-signal (signo)
(format *error-output* "~&received ~A~%" (signal-name signo))
(sb-ext:exit :code 1 :abort t))
(setf (signal-handler :term) #’exit-on-signal) ;; :term can also be :sigterm or 15
(loop (sleep 3))
;; now run ‘kill -15 $PID‘ on the terminal to run ‘exit-on-signal‘
“‘
Above example shows the usage of **toplevel handlers**.
Toplevel handlers are system wide and (in most cases) static.
## Usage: SIGNAL-HANDLER-BIND
The next important usage of trivial-signal is
to establish handlers dynamically by ‘signal-handler-bind‘.
The scope of this kind of signal handlers are thread-local.
When the main process receives a signal,
handlers are called in the same way as in ‘handler-bind‘ : the
top handler in the innermost ‘signal-handler-bind‘ is called first.
“‘COMMON-LISP
(use-package :trivial-signal)
(tagbody
(signal-handler-bind ((15 (lambda (c) (print :first)))
(15 (lambda (c) (print :escaping) (go :escape)))
;; mixing different handlers is ok
(2 (lambda (c) (print :escaping) (go :escape)))
;; once the signal is handled, remaining handlers are not called
(15 (lambda (c) (print :this-should-not-be-called))))
(loop (sleep 3))) ;; now send signal 15 from the terminal
:escape
(print :success!))
(tagbody
;; nested handlers are called from the most recently established ones.
;; If the handler declines, the next innermost one is called.
(signal-handler-bind ((15 (lambda (c) (print :this-should-not-be-called))))
(signal-handler-bind ((15 (lambda (c) (print :escaping) (go :escape))))
(signal-handler-bind ((15 (lambda (c) (print :most-recent))))
(loop (sleep 3)))))
:escape
(print :success!))
“‘
If all these thread-local handlers decline, then the toplevel handlers are called.
If that declines again, then a common-lisp condition ‘unix-signal‘ is
signaled in that context.
# Signal Handling Internal
Signals are handled by C-level posix ‘signal(8)‘ API
with which we set a low-level handler through CFFI.
## Some Signals may not Work Right
Note that, depending on the lisp implementation, some signals may not be
captured. This is related to the implementations’ internal, which may use
signals internally for their own sake (such as thread manipulation).
At least I checked the following signals work:
+ on SBCL x86_64, 4-8, 10-11, 16, 18, 21-22, 30-31, 34-64 (SIGRTMIN-SIGRTMAX)
+ if you set a signal handler on 13 (SIGPIPE), sbcl hangs up
+ on CCL x86_64, 1-3,6,8,10,12-14,16-18,21-24,26-29,31, 34-64 (SIGRTMIN-SIGRTMAX)
To see which signals works on your environment, see [TESTING.org](https://github.com/guicho271828/trivial-signal/blob/master/TESTING.org)
## Threading Policy
The C-level signal handlers call a lisp function, which interrupts each
thread who has thread-local signal handlers established by
‘signal-handler-bind‘.
Signals directly sent to each thread might not be captured by ‘trivial-signal‘.
The behavior is currently undefined.
Our advise is that they should be sent to the main process.
This is again related to the internal behavior of the implementations.
For example, on SBCL, signals sent to the main process are not
distributed to each thread. However, CCL seems to distribute the signals.
# API
## sigspec API
Signals can be either specified by its number or by its name.
In ‘trivial-signal‘, the name can be specified with keywords.
Below examples should be sufficient :
+ 15, :term, :sigterm (additionally, constant ‘+sigterm+‘ is bound to 15)
+ 2, :int, :sigint (additionally, constant ‘+sigint+‘ is bound to 2 )
+ 24, :xcpu, :sigxcpu (additionally, constant ‘+sigxcpu+‘ is bound to 24)
Note that the signal number actually depends on the OS you are using.
These numbers are obtained by ‘cffi-grovel‘, therefore OS level
compatibility is now fixed.
### [Function] signal-name (signo)
This returns the name of ‘SIGNO‘ as a keyword.
“‘common-lisp
(signal-name 15)
;=> :TERM
“‘
### [Function] signal-number (signame)
This returns the number of ‘SIGNAME‘ as an integer.
“‘common-lisp
(signal-number :term)
;=> 15
“‘
## Thread-local handlers API
#### [Macro] signal-handler-bind ([(sigspec handler)]* &body forms)
This executes ‘FORMS‘ in an environment where signal handler bindings are in effect.
“‘common-lisp
(signal-handler-bind ((:term (lambda (signo)
(declare (ignore signo))
(sb-ext:exit :abort t)))
(:int (lambda (signo)
(princ (signal-name signo) *error-output*))))
;; do something.
)
“‘
#### [Function] call-signal-handler-bind (new-signal-handlers fn)
Run FN in a dynamic environment where the signal handler bindings are
in effect. ‘new-signal-handlers‘ is a cons tree of ((signo handler ...) ...).
This is rather an internal function which signal-handler-bind expands into.
Use this function when you want to dynamically alter the signal to be captured.
Note that, trivial-signal only considers the first appearance of (signo handlers...)
with the matching signo in the same layer. For example,
(call-signal-handler-bind
‘((,*signo* ,(lambda (c) (lprint :first))
,(lambda (c) (lprint :escaping) (go :escape))
,(lambda (c) (lprint :this-should-not-be-called))))
(lambda () ...))
is okay but
(call-signal-handler-bind
‘((,*signo* ,(lambda (c) (lprint :first)))
(,*signo* ,(lambda (c) (lprint :escaping) (go :escape)))
(,*signo* ,(lambda (c) (lprint :this-should-not-be-called))))
(lambda () ... ))
is incorrect (the 2nd and 3rd handlers are ignored).
If you want to do it, wrap the main code in the ‘(lambda () ...)‘
with another call-signal-handler-bind.
(Also, the macro ‘signal-handler-bind‘ automatically solve this.)
#### [Macro] with-signal-handler (signal fn &body forms)
(deprecated)
This executes ‘FORMS‘ in an environment where a signal handler ‘FN‘ for a signal ‘SIGNAL‘ is in effect.
“‘common-lisp
(with-signal-handler :term (lambda (signo)
(declare (ignore signo))
(sb-ext:exit :abort t))
;; do something.
)
“‘
## Toplevel handlers
Toplevel handlers are system wide, global handlers that capture the signals
sent to the main process.
The functionality of the toplevel signal handlers are analogous to ‘*debugger-hook*‘.
When the lisp process receives a signal,
it is handled by these toplevel handlers
**unless** some nested signal handlers (described later) handles it.
“‘common-lisp
(use-package :trivial-signal)
(defun exit-on-signal (signo)
(format *error-output* "~&received ~A~%" (signal-name signo))
(sb-ext:exit :code 1 :abort t))
(signal-handler :term) ;=> NIL
(setf (signal-handler :term) #’exit-on-signal)
;=> #<FUNCTION (LAMBDA (SIGNO)) {1005764E3B}>
(signal-handler :term)
;=> #<FUNCTION (LAMBDA (SIGNO)) {1005764E3B}>
; T
;; Removing a signal handler.
(setf (signal-handler :term) nil) ; or: (remove-signal-handler :term) (deprecated)
;=> T
;; Clearing all signal handlers.
(remove-all-signal-handlers)
“‘
#### [Function] signal-handler (signal)
This returns a signal handler for a signal ‘SIGNAL‘.
‘SIGNAL‘ can be either a keyword or an integer.
“‘common-lisp
(signal-handler :term)
(signal-handler 15)
(signal-handler +sigterm+)
“‘
#### [Function] \(setf signal-handler) (fn signal)
This sets a signal handler ‘FN‘ for a signal ‘SIGNAL‘.
‘FN‘ must be a function or a symbol of a function name, which takes one
argument as a signal number.
Otherwise ‘FN‘ should be ‘NIL‘, indicating the handler should be removed.
“‘common-lisp
(setf (signal-handler :term)
#’(lambda (signo)
(princ (signal-name signo) *error-output*)))
“‘
#### [Function] remove-signal-handler (signal)
(deprecated) This removes a signal handler from a signal ‘SIGNAL‘.
#### [Function] remove-all-signal-handlers ()
This clears all signal handlers.
## Author
* Eitaro Fukamachi (e.arrows@gmail.com) (author)
* Masataro Asai (guicho2.71828@gmai.com) (maintainer)
## License
Trivial-signal is free and unencumbered software released into the public domain.
0.1.0
cffi-grovel
trivial-signal.asd (file)
src (module)
Modules are listed depth-first from the system components tree.
• The trivial-signal/src module |
trivial-signal (system)
src/
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
Next: The trivial-signal/src/packages․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
trivial-signal.asd
trivial-signal (system)
Next: The trivial-signal/src/grovel․lisp file, Previous: The trivial-signal․asd file, Up: Lisp files [Contents][Index]
src (module)
src/packages.lisp
Next: The trivial-signal/src/signals․lisp file, Previous: The trivial-signal/src/packages․lisp file, Up: Lisp files [Contents][Index]
packages.lisp (file)
src (module)
src/grovel.lisp
Next: The trivial-signal/src/trivial-signal․lisp file, Previous: The trivial-signal/src/grovel․lisp file, Up: Lisp files [Contents][Index]
grovel.lisp (file)
src (module)
src/signals.lisp
Previous: The trivial-signal/src/signals․lisp file, Up: Lisp files [Contents][Index]
signals.lisp (file)
src (module)
src/trivial-signal.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The trivial-signal-asd package | ||
• The trivial-signal.signals package | ||
• The trivial-signal package |
Next: The trivial-signal․signals package, Previous: Packages, Up: Packages [Contents][Index]
trivial-signal.asd
Next: The trivial-signal package, Previous: The trivial-signal-asd package, Up: Packages [Contents][Index]
packages.lisp (file)
common-lisp
Previous: The trivial-signal․signals package, Up: Packages [Contents][Index]
packages.lisp (file)
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported constants | ||
• Exported macros | ||
• Exported functions | ||
• Exported generic functions | ||
• Exported conditions |
Next: Exported macros, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Abort program (formerly SIGIOT).
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Real-time timer expired.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Bus error.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Child status has changed.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
A synonym for SIGCHLD.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Continue after stop.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Floating-point exception.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Terminal line hangup.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Illegal instruction.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Interrupt program.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
I/O is possible on a descriptor (see fcntl(2)).
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
IOT trap. A synonym for SIGABRT.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Kill program. Cannot be caught, blocked, or ignored.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Write on a pipe with no reader.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Pollable event (Sys V). Synonym of SIGIO.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Profiling timer alarm (see setitimer(2)).
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Power failure (System V)
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Quit program.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
SIGRTMAX in POSIX.1-2001, real time signal
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
SIGRTMIN in POSIX.1-2001, real time signal
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Segmentation violation.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Stop. Cannot be caught, blocked, or ignored.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Non-existent system call invoked.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Software termination signal.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Trace trap.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Stop signal generated from keyboard.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Background read attempted from control terminal.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Background write attempted to control terminal.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Unused signal (will be SIGSYS)
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Urgent condition present on socket.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
User defined signal 1.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
User defined signal 2.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Virtual time alarm (see setitimer(2)).
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Window size change.
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Cpu time limit exceeded (see setrlimit(2)).
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
File size limit exceeded (see setrlimit(2)).
/home/quickref/.cache/common-lisp/sbcl-1.5.8-linux-x64/home/quickref/quicklisp/dists/quicklisp/software/trivial-signal-20190710-git/src/grovel.processed-grovel-file
Next: Exported functions, Previous: Exported constants, Up: Exported definitions [Contents][Index]
Execute FORMS in a dynamic environment where thread-local signal handler bindings are
in effect.
The syntax is almost identical to cl:handler-bind. Example:
(tagbody
(signal-handler-bind ((15 (lambda (c) (print :first)))
(15 (lambda (c) (print :escaping) (go :escape)))
(2 (lambda (c) (print :escaping) (go :escape)))
(15 (lambda (c) (print :this-should-not-be-printed))))
(loop (sleep 3)))
:escape
(print :success!))
Now send signal 15 to the main lisp process using the terminal. It should
print :FIRST, :ESCAPING and :SUCCESS.
(Note: it does not work on some implementations, due to their
internals. In such cases, try another signal number, e.g. 10 !)
trivial-signal.lisp (file)
This is only for the backward compatibility
trivial-signal.lisp (file)
Next: Exported generic functions, Previous: Exported macros, Up: Exported definitions [Contents][Index]
Execute FN in a dynamic environment where signal handler bindings are
in effect. new-signal-handlers is a cons tree of ((signo handler ...) ...)
note that, trivial-signal only considers the first appearance of (signo handlers...)
with matching signo in the same layer. For example,
(call-signal-handler-bind
‘((,*signo* ,(lambda (c) (lprint :first))
,(lambda (c) (lprint :escaping) (go :escape))
,(lambda (c) (lprint :this-should-not-be-called))))
(lambda () ...))
is okay but
(call-signal-handler-bind
‘((,*signo* ,(lambda (c) (lprint :first)))
(,*signo* ,(lambda (c) (lprint :escaping) (go :escape)))
(,*signo* ,(lambda (c) (lprint :this-should-not-be-called))))
(lambda () ... ))
is incorrect (2nd and 3rd handlers are ignored).
If you want to do it wrap the main code in (lambda () ...)
with another call-signal-handler-bind.
trivial-signal.lisp (file)
Removes all toplevel signal handlers
trivial-signal.lisp (file)
Deprecated.
To remove the toplevel signal handler, (setf (signal-handler signo) nil) .
trivial-signal.lisp (file)
Returns the toplevel signal handler for a signal SIGNAL.
Toplevel handlers are system wide and (in most cases) static.
Unlike normal signal handlers, toplevel handlers can hold at most one
handler for the same signal.
Example:
(use-package :trivial-signal)
(defun exit-on-signal (signo)
(format *error-output* "~&received ~A~%" (signal-name signo))
(sb-ext:exit :code 1 :abort t))
(setf (signal-handler :term) #’exit-on-signal) ;; :term can also be :sigterm or 15
(loop (sleep 3))
trivial-signal.lisp (file)
(setf signal-handler) (function)
Set the toplevel signal handler FN for a signal SIGNAL. Toplevel handlers can hold at most one handler for the same signal.
trivial-signal.lisp (file)
signal-handler (function)
Return the name of SIGNO as a keyword.
signals.lisp (file)
Return the integer of SIGSPEC, which follows the sigspec API e.g. +SIGHUP+, :hup or :sighup.
signals.lisp (file)
Next: Exported conditions, Previous: Exported functions, Up: Exported definitions [Contents][Index]
trivial-signal.lisp (file)
Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
trivial-signal.lisp (file)
condition (condition)
signo (method)
:signo
signo (generic function)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal functions |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
trivial-signal.lisp (file)
trivial-signal.lisp (file)
trivial-signal.lisp (file)
per-thread flag for whether the current thread is listening signals
trivial-signal.lisp (file)
Nested cons-tree of signal handlers
trivial-signal.lisp (file)
signals.lisp (file)
Toplevel handler
trivial-signal.lisp (file)
Previous: Internal special variables, Up: Internal definitions [Contents][Index]
trivial-signal.lisp (file)
trivial-signal.lisp (file)
trivial-signal.lisp (file)
trivial-signal.lisp (file)
trivial-signal.lisp (file)
trivial-signal.lisp (file)
trivial-signal.lisp (file)
trivial-signal.lisp (file)
+SIGHUP+ -> :HUP
signals.lisp (file)
+SIGHUP+ -> :SIGHUP
signals.lisp (file)
returns an alist of ((name handler1 handler2 ...)=cons ...)
trivial-signal.lisp (file)
Handler-invoking procedure per thread
trivial-signal.lisp (file)
:HUP -> +SIGHUP+
signals.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L M T |
---|
Jump to: | F L M T |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | %
(
A C F G I K M R S W |
---|
Jump to: | %
(
A C F G I K M R S W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
+
C S |
---|
Jump to: | *
+
C S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C P S T U |
---|
Jump to: | C P S T U |
---|