The generic function
interface-preserve-state is called by
hcl:save-current-session just before it destroys an interface, on the interface process. You can specialize this for your own interface classes. Your methods should not interact with the user or other external sources, and should not interact with other processes, because it is called after
hcl:save-current-session already started to destroy interfaces.
CAPI User Guide and Reference Manual (Unix version) - 25 Feb 2015