Subject: Re: bug#24326: 25.1; Daemon doesn't exit on Windows if kill-emacs-hook asks a question

From: Eli Zaretskii <[email-masked]>
Date: Mon, 29 Aug 2016 17:38:11 +0300

> Date: Sun, 28 Aug 2016 22:09:51 +0300
> From: Eli Zaretskii <[email-masked]>
> 
> Not sure how to solve this.  One possibility would be to disable the
> "Save desktop?" question in this case, on MS-Windows only, and instead
> act as if the answer is NO.  desktop-kill is called from several
> places, so if we go this way, we will have to devise a way of figuring
> out that the question cannot be answered.

Actually, here's a simple solution:

diff --git a/lisp/server.el b/lisp/server.el
index 5300984..d34546d 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -648,7 +648,7 @@ server-start
 	  (add-hook 'delete-frame-functions 'server-handle-delete-frame)
 	  (add-hook 'kill-emacs-query-functions
                     'server-kill-emacs-query-function)
-	  (add-hook 'kill-emacs-hook 'server-force-stop) ;Cleanup upon exit.
+	  (add-hook 'kill-emacs-hook 'server-force-stop t) ;Cleanup upon exit.
 	  (setq server-process
 		(apply #'make-network-process
 		       :name server-name

I wonder if it ever makes sense for server.el to have its
kill-emacs-hook before any others.  server-force-stop deletes all the
client frames, so if there are no other frames, our capabilities to
communicate with the user are thereafter seriously degraded.

If the above is deemed too bold, we could do that only in the daemon,
using daemonp for the test.

Comments?