Does Emacs allow it to implement POSIX signal handling in Lisp?

Specifically, I would like to handle SIGTERM to finish desktop-mode related things.


1 Answer 1


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 ()
  (save-some-buffers t t)

(define-key special-event-map (kbd "<sigusr1>") 'my-quit-emacs-unconditionally)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.