3

I would like to call a function just before emacs exits. Normally the following can do job:

(add-hook 'kill-emacs-hook 'my-function)

Unfortunately when I shutdown the system (MS Windows) or terminating the emacs process by some external tools, this does not work.

Is it impossible to achieve this goal in such situations?

phils
  • 48,657
  • 3
  • 76
  • 115
Name
  • 7,689
  • 4
  • 38
  • 84

1 Answers1

2

The manual explicitly states that kill-emacs is called, running the kill-emacs-hook, when SIGTERM or SIGKILL is recieved. So I would call this a bug.

https://www.gnu.org/software/emacs/manual/html_node/elisp/Killing-Emacs.html

(I guess this has to do with how windows kills differently than POSIX, but it should be possible to implement the analog/correct behaviour.)

Vera Johanna
  • 873
  • 6
  • 9