[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Functions in kill-emacs-hook aren't run if emacs gets killed with SI
Re: Functions in kill-emacs-hook aren't run if emacs gets killed with SIGTERM
Tue, 03 Feb 2009 18:28:24 +0100
Thunderbird 126.96.36.199 (X11/20081125)
From: Tassilo Horn
> I don't get what could be so dangerous running a user-defined hook after
> all buffers have been saved, as Stefan suggested. The worst case I can
> imagine is that one of the functions accesses a file but is too slow,
> and a subsequent SIGKILL causes some data loss.
Actually it requires only three lines to get something that seems to
work quite nicely, at least for demonstration purposes.
Replace one line in emacs.c:~1315:
- signal (SIGTERM, fatal_error_signal);
+ add_user_signal (SIGTERM, "sigterm");
and add some lisp to catch the signal (can be put into .emacs, to begin with)
(define-key special-event-map [sigterm] 'sigterm-handler)
(defun sigterm-handler () (interactive) (kill-emacs))
Where kill-emacs will also run the kill-emacs-hooks in a safe way, as intended.
- Re: Functions in kill-emacs-hook aren't run if emacs gets killed with SIGTERM,