Does Emacs allow it to implement POSIX signal handling in Lisp?
Specifically, I would like to handle SIGTERM to finish desktop-mode related things.
Does Emacs allow it to implement POSIX signal handling in Lisp?
Specifically, I would like to handle SIGTERM to finish desktop-mode related things.
There's special-event-map
which can be used to handle signals among other things, you can bind a key like [sigusr2]
there to a function you'd like to be executed on the respective signal. I'm not so sure whether it works on anything else than SIGUSR1
and SIGUSR2
though.
edit: Here's an useful example of how one could use it:
(defun my-quit-emacs-unconditionally ()
(interactive)
(save-some-buffers t t)
(kill-emacs))
(define-key special-event-map (kbd "<sigusr1>") 'my-quit-emacs-unconditionally)