emacs-devel
[Top][All Lists]
Advanced

[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


From: grischka
Subject: Re: Functions in kill-emacs-hook aren't run if emacs gets killed with SIGTERM
Date: Tue, 03 Feb 2009 18:28:24 +0100
User-agent: Thunderbird 2.0.0.18 (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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]