From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: grischka Newsgroups: gmane.emacs.devel 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 Message-ID: <49887EB8.1060400@gmx.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1233682173 31342 80.91.229.12 (3 Feb 2009 17:29:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 3 Feb 2009 17:29:33 +0000 (UTC) Cc: emacs-devel@gnu.org To: tassilo@member.fsf.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 03 18:30:47 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LUP6d-0004sv-8O for ged-emacs-devel@m.gmane.org; Tue, 03 Feb 2009 18:30:39 +0100 Original-Received: from localhost ([127.0.0.1]:52906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUP5K-0008TC-C2 for ged-emacs-devel@m.gmane.org; Tue, 03 Feb 2009 12:29:18 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUP4g-0007rc-8l for emacs-devel@gnu.org; Tue, 03 Feb 2009 12:28:38 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUP4e-0007pB-Ji for emacs-devel@gnu.org; Tue, 03 Feb 2009 12:28:37 -0500 Original-Received: from [199.232.76.173] (port=34063 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUP4e-0007p1-Dh for emacs-devel@gnu.org; Tue, 03 Feb 2009 12:28:36 -0500 Original-Received: from mail.gmx.net ([213.165.64.20]:60025) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1LUP4d-0004M3-Qb for emacs-devel@gnu.org; Tue, 03 Feb 2009 12:28:36 -0500 Original-Received: (qmail invoked by alias); 03 Feb 2009 17:28:25 -0000 Original-Received: from p57A08FE5.dip0.t-ipconnect.de (EHLO [192.168.1.3]) [87.160.143.229] by mail.gmx.net (mp012) with SMTP; 03 Feb 2009 18:28:25 +0100 X-Authenticated: #18588216 X-Provags-ID: V01U2FsdGVkX1/qlQAdrJzqQUUaaFhqjdI7UTHoiIAAEdEI0766q2 V3evifAMZI3XEy User-Agent: Thunderbird 2.0.0.18 (X11/20081125) Original-References: 87hc3b6brl.fsf@thinkpad.tsdh.de X-Y-GMX-Trusted: 0 X-FuHaFi: 0.68 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:108696 Archived-At: 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.