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: Tassilo Horn
Subject: Re: Functions in kill-emacs-hook aren't run if emacs gets killed with SIGTERM
Date: Fri, 23 Jan 2009 16:58:03 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> I'm sure I understand what you mean by "enough", because I'm not sure
>> what you think is necessary.  To me what is necessary is:
>> 1 - don't lose data.
>> 2 - exit reasonably promptly.
>> So doing the autosaves before running the hook should make sure
>> 1 is preserved.  But running the hook may indeed make us lose 2.
>> Is that what you meant by "not enough"?
>> 
>> To keep number 2, we could schedule a SIGALRM so as to forcefully
>> exit after a timeout, in case running the hook doesn't happen quickly
>> enough.
>
> On balance, I would leave things as they are, i.e. don't run
> kill-emacs-hook when we get SIGTERM.  After all, we are being killed,
> so only the minimum necessary cleanup should be in order.

Well, at least it should be customizable (with Stefan's approach above).
Since I run emacs as daemon I create and delete frames on demand and
usually forget to terminate it manually before shutting down my
computer.  And in `kill-emacs-hook' I run some quite important functions
(save chat logs, recentf and stuff) which aren't executed when init
kills emacs with SIGTERM.

> If SIGTERM is used to programmatically shut down Emacs, I think it's
> rather a conceptual bug in whatever uses SIGTERM for that purpose.

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.

Bye,
Tassilo




reply via email to

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