unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs daemon doesn't terminate on SIGTERM any more
@ 2010-10-22  8:35 Ulrich Mueller
  2010-10-22 22:51 ` Ulrich Mueller
  0 siblings, 1 reply; 10+ messages in thread
From: Ulrich Mueller @ 2010-10-22  8:35 UTC (permalink / raw)
  To: emacs-devel

I start Emacs from BZR trunk in daemon mode and connect to it:

   $ emacs -Q --daemon
   ("emacs")
   Starting Emacs daemon.
   $ emacsclient -t

Then I try to kill it from another terminal window:

   $ kill <pid of emacs process>

With Emacs 23.2 the process would properly terminate now. The BZR
version asks for interactive input in the open terminal frame instead:

    The current server still has clients; delete them? (yes or no)

Therefore the process doesn't terminate. Is such a behaviour intended?
IMHO, a process should terminate on reception of a SIGTERM.

Ulrich



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs daemon doesn't terminate on SIGTERM any more
  2010-10-22  8:35 Emacs daemon doesn't terminate on SIGTERM any more Ulrich Mueller
@ 2010-10-22 22:51 ` Ulrich Mueller
  2010-10-23  8:59   ` Jan Djärv
  0 siblings, 1 reply; 10+ messages in thread
From: Ulrich Mueller @ 2010-10-22 22:51 UTC (permalink / raw)
  To: emacs-devel

>>>>> On Fri, 22 Oct 2010, Ulrich Mueller wrote:

> Then I try to kill it from another terminal window:

>    $ kill <pid of emacs process>

> With Emacs 23.2 the process would properly terminate now. The BZR
> version asks for interactive input in the open terminal frame instead:

>     The current server still has clients; delete them? (yes or no)

> Therefore the process doesn't terminate.

The problem is caused by the following change (introduced in May):

--- a/src/emacs.c
+++ b/src/emacs.c
@@ -385,6 +386,9 @@ fatal_error_signal (sig)
     {
       fatal_error_in_progress = 1;
 
+      if (sig == SIGTERM || sig == SIGHUP)
+        Fkill_emacs (make_number (sig));
+
       shut_down_emacs (sig, 0, Qnil);
     }
 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs daemon doesn't terminate on SIGTERM any more
  2010-10-22 22:51 ` Ulrich Mueller
@ 2010-10-23  8:59   ` Jan Djärv
  2010-10-23 18:40     ` Glenn Morris
  2010-10-24 16:06     ` Chong Yidong
  0 siblings, 2 replies; 10+ messages in thread
From: Jan Djärv @ 2010-10-23  8:59 UTC (permalink / raw)
  To: Ulrich Mueller; +Cc: emacs-devel



Ulrich Mueller skrev 2010-10-23 00.51:
>>>>>> On Fri, 22 Oct 2010, Ulrich Mueller wrote:
>
>> Then I try to kill it from another terminal window:
>
>>     $ kill<pid of emacs process>
>
>> With Emacs 23.2 the process would properly terminate now. The BZR
>> version asks for interactive input in the open terminal frame instead:
>
>>      The current server still has clients; delete them? (yes or no)
>
>> Therefore the process doesn't terminate.
>
> The problem is caused by the following change (introduced in May):
>
> --- a/src/emacs.c
> +++ b/src/emacs.c
> @@ -385,6 +386,9 @@ fatal_error_signal (sig)
>       {
>         fatal_error_in_progress = 1;
>
> +      if (sig == SIGTERM || sig == SIGHUP)
> +        Fkill_emacs (make_number (sig));
> +
>         shut_down_emacs (sig, 0, Qnil);
>       }
>

This was done so that kill-emacs-hook is run.  For example, desktop.el will 
then save its desktop when logging out from Gnome/KDE.

What Emacs needs is some sort of notion of when user interaction is not OK. 
For SIGTERM it is almost never ok, as it might be the window 
manager/system/whatever that is shutting down.  Even desktop.el will try to 
ask questions sometimes (i.e. desktop-save is set but there is no desktop file 
yet), which is annoying.  Maybe introduce some interaction-ok-p predicate?

	Jan D.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs daemon doesn't terminate on SIGTERM any more
  2010-10-23  8:59   ` Jan Djärv
@ 2010-10-23 18:40     ` Glenn Morris
  2010-10-24  8:48       ` Jan Djärv
  2010-10-24 16:06     ` Chong Yidong
  1 sibling, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2010-10-23 18:40 UTC (permalink / raw)
  To: Jan Djärv; +Cc: Ulrich Mueller, emacs-devel

Jan Djärv wrote:

> This was done so that kill-emacs-hook is run.  For example, desktop.el
> will then save its desktop when logging out from Gnome/KDE.
>
> What Emacs needs is some sort of notion of when user interaction is
> not OK. For SIGTERM it is almost never ok, as it might be the window
> manager/system/whatever that is shutting down.  Even desktop.el will
> try to ask questions sometimes (i.e. desktop-save is set but there is
> no desktop file yet), which is annoying.  Maybe introduce some
> interaction-ok-p predicate?

Things that might ask questions should be on kill-emacs-query-functions,
not kill-emacs-hook, shouldn't they?



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs daemon doesn't terminate on SIGTERM any more
  2010-10-23 18:40     ` Glenn Morris
@ 2010-10-24  8:48       ` Jan Djärv
  2010-10-24  9:17         ` Ulrich Mueller
  2010-10-24 19:41         ` Glenn Morris
  0 siblings, 2 replies; 10+ messages in thread
From: Jan Djärv @ 2010-10-24  8:48 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Ulrich Mueller, emacs-devel



Glenn Morris skrev 2010-10-23 20.40:
> Jan Djärv wrote:
>
>> This was done so that kill-emacs-hook is run.  For example, desktop.el
>> will then save its desktop when logging out from Gnome/KDE.
>>
>> What Emacs needs is some sort of notion of when user interaction is
>> not OK. For SIGTERM it is almost never ok, as it might be the window
>> manager/system/whatever that is shutting down.  Even desktop.el will
>> try to ask questions sometimes (i.e. desktop-save is set but there is
>> no desktop file yet), which is annoying.  Maybe introduce some
>> interaction-ok-p predicate?
>
> Things that might ask questions should be on kill-emacs-query-functions,
> not kill-emacs-hook, shouldn't they?

Not sure.  Things like desktop.el doesn't want to cancel the shutdown, just 
ask some questions.  The message that started this thread "The current server 
still has clients; delete them? (yes or no)" is from a function run from 
delete-frame-functions, which is run by delete-frame.

	Jan D.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs daemon doesn't terminate on SIGTERM any more
  2010-10-24  8:48       ` Jan Djärv
@ 2010-10-24  9:17         ` Ulrich Mueller
  2010-10-24 10:05           ` Jan Djärv
  2010-10-24 19:41         ` Glenn Morris
  1 sibling, 1 reply; 10+ messages in thread
From: Ulrich Mueller @ 2010-10-24  9:17 UTC (permalink / raw)
  To: Jan Djärv; +Cc: emacs-devel

>>>>> On Sun, 24 Oct 2010, Jan Djärv wrote:

>>> What Emacs needs is some sort of notion of when user interaction
>>> is not OK. For SIGTERM it is almost never ok, as it might be the
>>> window manager/system/whatever that is shutting down. Even
>>> desktop.el will try to ask questions sometimes (i.e. desktop-save
>>> is set but there is no desktop file yet), which is annoying. Maybe
>>> introduce some interaction-ok-p predicate?
>> 
>> Things that might ask questions should be on
>> kill-emacs-query-functions, not kill-emacs-hook, shouldn't they?

> Not sure. Things like desktop.el doesn't want to cancel the
> shutdown, just ask some questions. The message that started this
> thread "The current server still has clients; delete them? (yes or
> no)" is from a function run from delete-frame-functions, which is
> run by delete-frame.

As far as I can see, the question is asked in function server-start.
Which in turn is called from kill-emacs-hook via function server-mode.

Also it doesn't make any difference if one answers the question with
yes or with no. The shutdown will proceed in either case.

Ulrich



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs daemon doesn't terminate on SIGTERM any more
  2010-10-24  9:17         ` Ulrich Mueller
@ 2010-10-24 10:05           ` Jan Djärv
  0 siblings, 0 replies; 10+ messages in thread
From: Jan Djärv @ 2010-10-24 10:05 UTC (permalink / raw)
  To: Ulrich Mueller; +Cc: emacs-devel



Ulrich Mueller skrev 2010-10-24 11.17:
>>>>>> On Sun, 24 Oct 2010, Jan Djärv wrote:
>
>>>> What Emacs needs is some sort of notion of when user interaction
>>>> is not OK. For SIGTERM it is almost never ok, as it might be the
>>>> window manager/system/whatever that is shutting down. Even
>>>> desktop.el will try to ask questions sometimes (i.e. desktop-save
>>>> is set but there is no desktop file yet), which is annoying. Maybe
>>>> introduce some interaction-ok-p predicate?
>>>
>>> Things that might ask questions should be on
>>> kill-emacs-query-functions, not kill-emacs-hook, shouldn't they?
>
>> Not sure. Things like desktop.el doesn't want to cancel the
>> shutdown, just ask some questions. The message that started this
>> thread "The current server still has clients; delete them? (yes or
>> no)" is from a function run from delete-frame-functions, which is
>> run by delete-frame.
>
> As far as I can see, the question is asked in function server-start.
> Which in turn is called from kill-emacs-hook via function server-mode.
>

Correct, I must have looked at the wrong function.

	Jan D.

> Also it doesn't make any difference if one answers the question with
> yes or with no. The shutdown will proceed in either case.
>
> Ulrich



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs daemon doesn't terminate on SIGTERM any more
  2010-10-23  8:59   ` Jan Djärv
  2010-10-23 18:40     ` Glenn Morris
@ 2010-10-24 16:06     ` Chong Yidong
  2010-10-25  5:42       ` Jan Djärv
  1 sibling, 1 reply; 10+ messages in thread
From: Chong Yidong @ 2010-10-24 16:06 UTC (permalink / raw)
  To: Jan Djärv; +Cc: Ulrich Mueller, emacs-devel

Jan Djärv <jan.h.d@swipnet.se> writes:

> This was done so that kill-emacs-hook is run.  For example, desktop.el
> will then save its desktop when logging out from Gnome/KDE.
>
> What Emacs needs is some sort of notion of when user interaction is
> not OK. For SIGTERM it is almost never ok, as it might be the window
> manager/system/whatever that is shutting down.  Even desktop.el will
> try to ask questions sometimes (i.e. desktop-save is set but there is
> no desktop file yet), which is annoying.  Maybe introduce some
> interaction-ok-p predicate?

How about it, in response to a kill signal, we do

  noninteractive = 1;

before calling Fkill_emacs?



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs daemon doesn't terminate on SIGTERM any more
  2010-10-24  8:48       ` Jan Djärv
  2010-10-24  9:17         ` Ulrich Mueller
@ 2010-10-24 19:41         ` Glenn Morris
  1 sibling, 0 replies; 10+ messages in thread
From: Glenn Morris @ 2010-10-24 19:41 UTC (permalink / raw)
  To: Jan Djärv; +Cc: Ulrich Mueller, emacs-devel

Jan Djärv wrote:

> Not sure.  Things like desktop.el doesn't want to cancel the shutdown,
> just ask some questions. 

I haven't looked at it properly, but I think maybe
kill-emacs-query-functions does the right thing, but has a bad
name/doc. Maybe it should be described as "List of functions to run
when killing Emacs that need to interact with the user. Additionally,
if any of them returns nil, killing Emacs is cancelled."



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Emacs daemon doesn't terminate on SIGTERM any more
  2010-10-24 16:06     ` Chong Yidong
@ 2010-10-25  5:42       ` Jan Djärv
  0 siblings, 0 replies; 10+ messages in thread
From: Jan Djärv @ 2010-10-25  5:42 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Ulrich Mueller, emacs-devel



Chong Yidong skrev 2010-10-24 18.06:
> Jan Djärv<jan.h.d@swipnet.se>  writes:
>
>> This was done so that kill-emacs-hook is run.  For example, desktop.el
>> will then save its desktop when logging out from Gnome/KDE.
>>
>> What Emacs needs is some sort of notion of when user interaction is
>> not OK. For SIGTERM it is almost never ok, as it might be the window
>> manager/system/whatever that is shutting down.  Even desktop.el will
>> try to ask questions sometimes (i.e. desktop-save is set but there is
>> no desktop file yet), which is annoying.  Maybe introduce some
>> interaction-ok-p predicate?
>
> How about it, in response to a kill signal, we do
>
>    noninteractive = 1;
>
> before calling Fkill_emacs?

That would be fine as long as code has something to look for.  We would have 
to go through those that out themselves into kill-emacs-hook and modify them, 
perhaps starting with server.el and desktop.el first.

	Jan D.



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-10-25  5:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-22  8:35 Emacs daemon doesn't terminate on SIGTERM any more Ulrich Mueller
2010-10-22 22:51 ` Ulrich Mueller
2010-10-23  8:59   ` Jan Djärv
2010-10-23 18:40     ` Glenn Morris
2010-10-24  8:48       ` Jan Djärv
2010-10-24  9:17         ` Ulrich Mueller
2010-10-24 10:05           ` Jan Djärv
2010-10-24 19:41         ` Glenn Morris
2010-10-24 16:06     ` Chong Yidong
2010-10-25  5:42       ` Jan Djärv

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).