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: Wed, 21 Jan 2009 19:49:13 +0000 Message-ID: <87eiywcudi.fsf@thinkpad.tsdh.de> References: <87prihxeu5.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 1232567651 10309 80.91.229.12 (21 Jan 2009 19:54:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Jan 2009 19:54:11 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 21 20:55:23 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 1LPjAS-0004TJ-Aq for ged-emacs-devel@m.gmane.org; Wed, 21 Jan 2009 20:55:16 +0100 Original-Received: from localhost ([127.0.0.1]:34657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LPj9A-0004wE-Mu for ged-emacs-devel@m.gmane.org; Wed, 21 Jan 2009 14:53:56 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LPj4m-0007os-L8 for emacs-devel@gnu.org; Wed, 21 Jan 2009 14:49:24 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LPj4l-0007mq-4k for emacs-devel@gnu.org; Wed, 21 Jan 2009 14:49:23 -0500 Original-Received: from [199.232.76.173] (port=39231 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LPj4k-0007mZ-Je for emacs-devel@gnu.org; Wed, 21 Jan 2009 14:49:22 -0500 Original-Received: from out1.smtp.messagingengine.com ([66.111.4.25]:47653) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LPj4i-0005Gf-Py; Wed, 21 Jan 2009 14:49:20 -0500 Original-Received: from compute2.internal (compute2.internal [10.202.2.42]) by out1.messagingengine.com (Postfix) with ESMTP id 5B2E72498F8; Wed, 21 Jan 2009 14:49:19 -0500 (EST) Original-Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute2.internal (MEProxy); Wed, 21 Jan 2009 14:49:19 -0500 X-Sasl-enc: nLjrj2s7MGBWcZFbuIBhQqDkavZiOf+QdgACT7rAjWNn 1232567358 Original-Received: from thinkpad.tsdh.de (p54AF2728.dip0.t-ipconnect.de [84.175.39.40]) by mail.messagingengine.com (Postfix) with ESMTPA id 3D3D52237F; Wed, 21 Jan 2009 14:49:17 -0500 (EST) Mail-Followup-To: Eli Zaretskii , emacs-devel@gnu.org 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:108046 Archived-At: Eli Zaretskii writes: Hi Eli, >> How does emacs handle SIGTERM? Doesn't it simply run `kill-emacs'? > > No. Fatal signals, such as SIGTERM, are caught by a signal handler, > which runs emacs.c:shut_down_emacs. `kill-emacs' in a nutshell runs > `kill-emacs-hook' and then also calls shut_down_emacs. Hm, at least if emacs runs as a daemon, I'd say that a simple "killall emacs" (most probably by some script) is the standard way of stopping it. Nobody wants to open a new frame just to shutdown emacs. >> At least that's what I would expect. > > I don't think it's a good idea to run Lisp code from within a fatal > signal handler. shut_down_emacs saves all unsaved buffers and cleans > up the terminal, but doesn't do anything else, because Emacs's > internal data structures can be very unstable at this point. So what's the right way to shutdown emacs running as a daemon noninteractively? emacsclient --eval '(kill-emacs)' queries for user input and waits till one connects and answers. Bye, Tassilo