The exit-hooks Reference Manual

Table of Contents

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

The exit-hooks Reference Manual

This is the exit-hooks Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 03:52:00 2018 GMT+0.


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

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]].


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

2 Systems

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


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

2.1 exit-hooks

Author

Bo Yao <icerove@gmail.com>

License

BSD

Description

Call registered function when Common Lisp Exits.

Source

exit-hooks.asd (file)

Components

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

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 files   [Contents][Index]

3.1.1 exit-hooks.asd

Location

exit-hooks.asd

Systems

exit-hooks (system)


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

3.1.2 exit-hooks/package.lisp

Parent

exit-hooks (system)

Location

package.lisp

Packages

exit-hooks


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

3.1.3 exit-hooks/exit-hooks.lisp

Dependency

package.lisp (file)

Parent

exit-hooks (system)

Location

exit-hooks.lisp

Exported Definitions

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

4 Packages

Packages are listed by definition order.


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

4.1 exit-hooks

Source

package.lisp (file)

Use List

common-lisp

Exported Definitions

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

5 Definitions

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


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

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Symbol macros

Symbol Macro: *exit-hooks*
Package

exit-hooks

Source

exit-hooks.lisp (file)

Expansion

*exit-hooks*


Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: add-exit-hook FUNC
Package

exit-hooks

Source

exit-hooks.lisp (file)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   E   F   L  
Index Entry  Section

E
exit-hooks.asd: The exit-hooks<dot>asd file
exit-hooks/exit-hooks.lisp: The exit-hooks/exit-hooks<dot>lisp file
exit-hooks/package.lisp: The exit-hooks/package<dot>lisp file

F
File, Lisp, exit-hooks.asd: The exit-hooks<dot>asd file
File, Lisp, exit-hooks/exit-hooks.lisp: The exit-hooks/exit-hooks<dot>lisp file
File, Lisp, exit-hooks/package.lisp: The exit-hooks/package<dot>lisp file

L
Lisp File, exit-hooks.asd: The exit-hooks<dot>asd file
Lisp File, exit-hooks/exit-hooks.lisp: The exit-hooks/exit-hooks<dot>lisp file
Lisp File, exit-hooks/package.lisp: The exit-hooks/package<dot>lisp file

Jump to:   E   F   L  

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

A.2 Functions

Jump to:   A   F  
Index Entry  Section

A
add-exit-hook: Exported functions

F
Function, add-exit-hook: Exported functions

Jump to:   A   F  

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

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*exit-hooks*: Exported symbol macros

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

Jump to:   *  
S  

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

A.4 Data types

Jump to:   E   P   S  
Index Entry  Section

E
exit-hooks: The exit-hooks system
exit-hooks: The exit-hooks package

P
Package, exit-hooks: The exit-hooks package

S
System, exit-hooks: The exit-hooks system

Jump to:   E   P   S