The exit-hooks Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The exit-hooks Reference Manual

This is the exit-hooks Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 04:30:56 2022 GMT+0.

Table of Contents


1 Introduction

* exit-hooks
exit-hooks provide a portable way to automatically call some user defined function when exit Common Lisp (Both ~(quit)~ from REPL or kill in shell). Like ~atexit~ in C and Python or Java's ~Runtime.addShutdownHook()~. It currently support SBCL, CCL, ECL, ABCL, Allegro CL, clisp and CMUCL. Before exit-hooks, there is no portable way to doing so and no staightforward way to use an exit hook on ABCL. It can be used for tasks like parmenantly save something when exit Lisp.

** Installation
#+BEGIN_SRC lisp
(ql:quickload :exit-hooks)

#+END_SRC

** Usage
To add a function FUNC called when Common Lisp exits:
#+BEGIN_SRC lisp
(exit-hooks:add-exit-hook #'func)
#+END_SRC
The function FUNC must be of zero arguments. If several functions are added this way, their calling sequence is not specified. If you want to call them in a specific sequence, you can simply wrap them into a single function and add it.

To visit current exit hooks or delete one, you can visit or delete elements from variable ~exit-hooks:*exit-hooks*~, it's a list contains current exit hooks. But you should not add exit hooks by adding elements to ~*exit-hooks*~, use ~add-exit-hook~ only, because elements in ~*exit-hooks*~ is implementation specific. 

** Acknowledgements
Thanks to Vibhu Mohindra from ABCL mail list and R. Matthew Emerson from OpenMCL mail list. They provide methods for exit-hooks for ABCL and CCL. And Jocelyn Fréchot gives many useful suggestions and support for clisp, Allegro CL and CMUCL. 

** Limitations
For some implementation, for example SBCL, when you are using SLIME, you need to exit Lisp in ~*inferior-lisp*~, not ~*slime-repl*~. If you directly run Lisp from shell, not in SLIME, there is no problem. Currently exit-hooks support most of popular Lisp implementations, but not all. If your implementation is not supported and you know how to do that, please tell me. Your work maybe helpful to other fellow Lispers. And this Library only provide a calling function when exit Lisp. Previous version of exit-hooks provide ability to add exit hooks with calling priority, but this can be easily done by wrap several functions into a single one and most people only want a portable layer so this is removed. If you want something to deal all kinds of OS signal handling capability you may have a look at [[https://github.com/guicho271828/trivial-signal][trivial-signal]].


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 exit-hooks

Call registered function when Common Lisp Exits.

Author

Bo Yao <icerove@gmail.com>

License

BSD

Source

exit-hooks.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 exit-hooks/exit-hooks.asd

Source

exit-hooks.asd.

Parent Component

exit-hooks (system).

ASDF Systems

exit-hooks.


3.1.2 exit-hooks/package.lisp

Source

exit-hooks.asd.

Parent Component

exit-hooks (system).

Packages

exit-hooks.


3.1.3 exit-hooks/exit-hooks.lisp

Dependency

package.lisp (file).

Source

exit-hooks.asd.

Parent Component

exit-hooks (system).

Public Interface

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 exit-hooks

Source

package.lisp.

Use List

common-lisp.

Public Interface

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Symbol macros

Symbol Macro: *exit-hooks*
Package

exit-hooks.

Source

exit-hooks.lisp.


5.1.2 Ordinary functions

Function: add-exit-hook (func)
Package

exit-hooks.

Source

exit-hooks.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   A   F  
Index Entry  Section

A
add-exit-hook: Public ordinary functions

F
Function, add-exit-hook: Public ordinary functions

Jump to:   A   F  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*exit-hooks*: Public symbol macros

S
Symbol Macro, *exit-hooks*: Public symbol macros

Jump to:   *  
S