From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: Functions in kill-emacs-hook aren't run if emacs gets killed with SIGTERM Date: Sat, 24 Jan 2009 10:04:00 +0100 Message-ID: <874ozpm5xb.fsf@thinkpad.tsdh.de> References: <87prihxeu5.fsf@thinkpad.tsdh.de> <87ab9iggl0.fsf@thinkpad.tsdh.de> <497A20D6.4050208@harpegolden.net> <87vds5fx0j.fsf@thinkpad.tsdh.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1232787887 15926 80.91.229.12 (24 Jan 2009 09:04:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 24 Jan 2009 09:04:47 +0000 (UTC) Cc: emacs-devel@gnu.org To: Lennart Borgman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 24 10:06:00 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 1LQeSN-0004E3-DD for ged-emacs-devel@m.gmane.org; Sat, 24 Jan 2009 10:05:53 +0100 Original-Received: from localhost ([127.0.0.1]:57830 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQeR5-0004OZ-Ut for ged-emacs-devel@m.gmane.org; Sat, 24 Jan 2009 04:04:15 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LQeR0-0004Ln-82 for emacs-devel@gnu.org; Sat, 24 Jan 2009 04:04:10 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LQeQz-0004Kv-DB for emacs-devel@gnu.org; Sat, 24 Jan 2009 04:04:09 -0500 Original-Received: from [199.232.76.173] (port=37349 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQeQz-0004Ks-9I for emacs-devel@gnu.org; Sat, 24 Jan 2009 04:04:09 -0500 Original-Received: from out3.smtp.messagingengine.com ([66.111.4.27]:36847) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LQeQy-0004dM-J7 for emacs-devel@gnu.org; Sat, 24 Jan 2009 04:04:08 -0500 Original-Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.fastmail.fm (Postfix) with ESMTP id 108BE255BA9; Sat, 24 Jan 2009 04:04:08 -0500 (EST) Original-Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Sat, 24 Jan 2009 04:04:08 -0500 X-Sasl-enc: mmSWX5i0o35MKi41iOGEB4JadSMLZUp0OUxm2wVs6cAP 1232787847 Original-Received: from thinkpad.tsdh.de (p54AF0F64.dip0.t-ipconnect.de [84.175.15.100]) by mail.messagingengine.com (Postfix) with ESMTPA id DD8C212B58; Sat, 24 Jan 2009 04:04:06 -0500 (EST) Mail-Copies-To: never Mail-Followup-To: Lennart Borgman , emacs-devel@gnu.org In-Reply-To: (Lennart Borgman's message of "Sat, 24 Jan 2009 00:13:13 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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:108181 Archived-At: Lennart Borgman writes: Hi Lennart, >>> And Emacs obeys this. The argument is not whether Emacs obeys >>> SIGTERM, the argument is whether user-defined hooks should run when >>> we are hit with SIGTERM. >> >> 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. >> >> But with the current way *every* SIGTERM causes data loss for me. > > I did not follow this closely, but maybe this is hitting a problem in > GNU/Linux? > > I compare with w32 where the shutdown process waits if some program > has problem exiting. That's the same on GNU/Linux, too. When the system goes down all apps receive a SIGTERM to shut down cleanly and after some seconds a SIGKILL is sent to the ones that didn't terminate. So IMO running `kill-emacs-hook' on SIGTERM (after saving all unsaved buffers) is the right thing to do, because that's the hook which is supposed to do all high-level cleanup stuff. Concering these "inconsistent state" discussions: How about adding some more text to the docstring of `kill-emacs-hook' explaining that user's shouldn't put very time intensive functions there, and that in some situations something may go wrong. > Regarding Stefans suggestion the only useful thing to do is AFAICS to > save some things to a file, so yes, there might be a problem - but > probably not worse than doing nothing. The saving on unsaved buffers is done with the current implementation, too. Stefan suggested to do that first, then to run `kill-emacs-hook' and then to shutdown. That's exactly what I expected before I recognized that I'm losing data when shutting down the computer without terminating the emacs daemon manually. Bye, Tassilo