unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David De La Harpe Golden <david@harpegolden.net>
To: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Functions in kill-emacs-hook aren't run if emacs gets killed with	SIGTERM
Date: Fri, 23 Jan 2009 19:56:06 +0000	[thread overview]
Message-ID: <497A20D6.4050208@harpegolden.net> (raw)
In-Reply-To: <u63k5vo4n.fsf@gnu.org>

Eli Zaretskii wrote:
>> From: Tassilo Horn <tassilo@member.fsf.org>
>> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,  emacs-devel@gnu.org
>> Date: Fri, 23 Jan 2009 16:58:03 +0100
>>
>> Init or start-stop-daemon do that.
>>
>>> Why can't they use SIGUSRn?
>> Because SIGUSRn has different meanings across applications, so the only
>> reliable way to terminate a program is "kill <pid>" which send a
>> SIGTERM.
> 
> You can run your own script when the machine is shut down, can't you?
> Then have that script deliver a SIGUSRn signal to Emacs and wait a few
> moments for it to shut down peacefully.
> 


Uh, but SIGTERM IS "please shutdown". Sorry, but _conventionally_ 
automated systems* will issue a SIGTERM to allow graceful shutdown, then 
a SIGKILL a few seconds later if the process hasn't promptly terminated 
like a good little process should.

This is mere convention on unix and gnu, but is a very long standing one 
at this stage? Certainly USRn shouldn't be used where TERM would do and 
is conventional...

SIGKILL, of course, is not a normal signal, it's a signal to the kernel 
to kill and eat the process whether the process likes it or not. But 
SIGTERM is a normal signal and it's IMO fine for emacs to do lots of
cleanup actions before exit upon its receipt.  So long as the emergency 
  save happens ASAP, I'd consider dropping back to the main
loop having queued an event that runs kill emacs hooks then exits upon 
SIGTERM (avoiding issues with running lisp code directly from a signal 
handler)- if there's a bug in one of the hooks, well, that just means 
emacs will then be kill -9'd, but that's life.

SIGUSR1 should maybe close and reopen the emacsclient socket
(see init, where USR1 closes and reopens the socket).

* initscripts/daemon managers, batch systems like PBS...

e.g.

"When init is requested to change the runlevel, it sends the warning 
signal SIGTERM to all processes that are undefined in the new runlevel. 
It then waits 5 seconds before forcibly terminating these processes via 
the SIGKILL signal."  - init

"All processes are first notified that the system is going down by the 
signal SIGTERM. This gives programs like vi(1) the time to save the file 
being edited, mail and news processing programs a chance to exit 
cleanly, etc"  - shutdown

  "A batch job being deleted by a server will be sent a SIGTERM signal 
following by a SIGKILL signal. The time delay between the two signals is 
an attribute of the execution queue... " - qdel (from PBS.)




  reply	other threads:[~2009-01-23 19:56 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-21  8:06 Functions in kill-emacs-hook aren't run if emacs gets killed with SIGTERM Tassilo Horn
2009-01-21 18:42 ` Eli Zaretskii
2009-01-21 19:49   ` Tassilo Horn
2009-01-21 20:35     ` Chong Yidong
2009-01-22  9:03       ` Tassilo Horn
2009-01-21 20:36   ` Stefan Monnier
2009-01-22  4:09     ` Eli Zaretskii
2009-01-22  9:00       ` Tassilo Horn
2009-01-22 18:23         ` Eli Zaretskii
2009-01-23  2:15           ` mail
2009-01-23 12:05             ` Eli Zaretskii
2009-01-22 10:08       ` Andreas Schwab
2009-01-22 18:25         ` Eli Zaretskii
2009-01-23  1:52         ` Richard M Stallman
2009-01-22 14:41       ` Stefan Monnier
2009-01-22 18:32         ` Eli Zaretskii
2009-01-22 21:16           ` Stefan Monnier
2009-01-23 15:25             ` Eli Zaretskii
2009-01-23 15:58               ` Tassilo Horn
2009-01-23 19:06                 ` Eli Zaretskii
2009-01-23 19:56                   ` David De La Harpe Golden [this message]
2009-01-23 22:39                     ` Eli Zaretskii
2009-01-23 23:00                       ` Tassilo Horn
2009-01-23 23:13                         ` Lennart Borgman
2009-01-24  9:04                           ` Tassilo Horn
2009-01-24  9:59                             ` Eli Zaretskii
2009-01-24 12:34                               ` Miles Bader
2009-01-24 10:00                             ` Eli Zaretskii
2009-01-23 20:33                   ` Dan Nicolaescu
2009-01-23 22:37                     ` Eli Zaretskii
2009-01-24  4:40               ` Jason Rumney
2009-01-24  6:11                 ` Miles Bader
2009-01-23  1:52         ` Richard M Stallman
  -- strict thread matches above, loose matches on Subject: below --
2009-01-23 19:01 grischka
2009-01-23 22:52 ` Eli Zaretskii
2009-01-24 14:16   ` grischka
2009-01-24 16:14     ` Eli Zaretskii
2009-01-24 17:56       ` grischka
2009-01-24 18:20         ` Eli Zaretskii
2009-01-24 19:11           ` grischka
2009-01-24 20:08             ` Eli Zaretskii
2009-01-24 20:28               ` grischka
2009-01-24 20:32 Stefan Monnier
2009-02-02 20:23 ` Eli Zaretskii
2009-02-02 20:52   ` Tassilo Horn
2009-02-02 21:09     ` Eli Zaretskii
2009-02-03 10:43       ` Tassilo Horn
2009-02-05  3:34   ` Stefan Monnier
2009-01-24 20:39 Stefan Monnier
2009-02-03 17:28 grischka
2009-02-05  3:37 ` Stefan Monnier
2009-02-05 13:31   ` grischka
2009-02-05 19:40     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=497A20D6.4050208@harpegolden.net \
    --to=david@harpegolden.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).