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: Sat, 24 Jan 2009 10:04:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Lennart Borgman <address@hidden> 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




reply via email to

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