From unknown Tue Aug 19 07:27:16 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#24326 <24326@debbugs.gnu.org> To: bug#24326 <24326@debbugs.gnu.org> Subject: Status: 25.1; Daemon doesn't exit on Windows if kill-emacs-hook asks a question Reply-To: bug#24326 <24326@debbugs.gnu.org> Date: Tue, 19 Aug 2025 14:27:16 +0000 retitle 24326 25.1; Daemon doesn't exit on Windows if kill-emacs-hook asks = a question reassign 24326 emacs submitter 24326 Eli Zaretskii severity 24326 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 28 15:10:23 2016 Received: (at submit) by debbugs.gnu.org; 28 Aug 2016 19:10:23 +0000 Received: from localhost ([127.0.0.1]:43010 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1be5TL-000371-4W for submit@debbugs.gnu.org; Sun, 28 Aug 2016 15:10:23 -0400 Received: from eggs.gnu.org ([208.118.235.92]:32973) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1be5TJ-00036m-Ue for submit@debbugs.gnu.org; Sun, 28 Aug 2016 15:10:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1be5TC-0000sG-DJ for submit@debbugs.gnu.org; Sun, 28 Aug 2016 15:10:16 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:43879) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1be5TB-0000rR-Pd for submit@debbugs.gnu.org; Sun, 28 Aug 2016 15:10:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1be5T9-0001EA-Fx for bug-gnu-emacs@gnu.org; Sun, 28 Aug 2016 15:10:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1be5T5-0000me-68 for bug-gnu-emacs@gnu.org; Sun, 28 Aug 2016 15:10:10 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:53496) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1be5T5-0000l6-1m for bug-gnu-emacs@gnu.org; Sun, 28 Aug 2016 15:10:07 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3096 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1be5T2-0003eC-E8 for bug-gnu-emacs@gnu.org; Sun, 28 Aug 2016 15:10:05 -0400 Date: Sun, 28 Aug 2016 22:09:51 +0300 Message-Id: <83shtobthc.fsf@gnu.org> From: Eli Zaretskii To: bug-gnu-emacs@gnu.org Subject: 25.1; Daemon doesn't exit on Windows if kill-emacs-hook asks a question X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -6.5 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.5 (------) Arrange for ~/.emacs to turn on desktop-save-mode in a way that causes Emacs to ask whether to save desktop on exit, then start a daemon like this emacsclient -c --alternate-editor="" SOME-FILE When a frame opens and shows a buffer visiting SOME-FILE, type M-x kill-emacs RET The frame will close, and emacsclient will exit, but the daemon it started will remain running. Worse, the daemon has shut down the server, so you cannot communicate with it, only kill it. The problem is that when Emacs asks whether to save the desktop, the user doesn't see the question, and even if she did, she cannot answer it because, with the last frame gone, there's no window procedure to supply input, so Emacs is stuck in pselect waiting for input that will never come. Unfortunately, a very similar situation happens when the last client frame is closed, but the daemon is not killed: in that case, Emacs waits in pselect for the next connection. So it is not easy to distinguish this situation from a daemon waiting normally for a connection. 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. In GNU Emacs 25.1.25 (i686-pc-mingw32) of 2016-08-27 built on HOME-C4E4A596F7 Repository revision: 17197d0ae9eac100b56078b2a48964b29710b76e Windowing system distributor 'Microsoft Corp.', version 5.1.2600 Configured using: 'configure --prefix=/d/usr --enable-checking=yes,glyphs --with-wide-int --with-modules 'CFLAGS=-O0 -gdwarf-4 -g3'' Configured features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS MODULES Important settings: value of $LANG: ENU locale-coding-system: cp1255 Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message dired format-spec rfc822 mml mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode easymenu cl-loaddefs pcase cl-lib mail-prsvr mail-utils time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel dos-w32 ls-lisp disp-table w32-win w32-vars term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote w32notify w32 multi-tty make-network-process emacs) Memory information: ((conses 16 93483 7377) (symbols 56 20757 0) (miscs 48 46 129) (strings 16 17781 5277) (string-bytes 1 441671) (vectors 16 12446) (vector-slots 8 432676 5026) (floats 8 162 229) (intervals 40 263 99) (buffers 856 21)) From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 29 10:38:24 2016 Received: (at 24326) by debbugs.gnu.org; 29 Aug 2016 14:38:24 +0000 Received: from localhost ([127.0.0.1]:43705 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1beNhg-0007vp-Fx for submit@debbugs.gnu.org; Mon, 29 Aug 2016 10:38:24 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1beNhe-0007vb-Ix for 24326@debbugs.gnu.org; Mon, 29 Aug 2016 10:38:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1beNhV-00074W-CU for 24326@debbugs.gnu.org; Mon, 29 Aug 2016 10:38:17 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:35871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beNhV-00074R-7e for 24326@debbugs.gnu.org; Mon, 29 Aug 2016 10:38:13 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4289 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1beNhT-0003P0-By for 24326@debbugs.gnu.org; Mon, 29 Aug 2016 10:38:11 -0400 Date: Mon, 29 Aug 2016 17:38:11 +0300 Message-Id: <83mvjvbpyk.fsf@gnu.org> From: Eli Zaretskii To: 24326@debbugs.gnu.org In-reply-to: <83shtobthc.fsf@gnu.org> (message from Eli Zaretskii on Sun, 28 Aug 2016 22:09:51 +0300) Subject: Re: bug#24326: 25.1; Daemon doesn't exit on Windows if kill-emacs-hook asks a question References: <83shtobthc.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.5 (------) X-Debbugs-Envelope-To: 24326 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.5 (------) > Date: Sun, 28 Aug 2016 22:09:51 +0300 > From: Eli Zaretskii > > 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? From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 12 14:28:04 2016 Received: (at 24326-done) by debbugs.gnu.org; 12 Sep 2016 18:28:04 +0000 Received: from localhost ([127.0.0.1]:57911 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjVxb-0002Dt-Po for submit@debbugs.gnu.org; Mon, 12 Sep 2016 14:28:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51521) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjVxa-0002DN-8z for 24326-done@debbugs.gnu.org; Mon, 12 Sep 2016 14:28:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjVxR-0006xN-Sp for 24326-done@debbugs.gnu.org; Mon, 12 Sep 2016 14:27:57 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_20,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjVxR-0006wW-Qe for 24326-done@debbugs.gnu.org; Mon, 12 Sep 2016 14:27:53 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1977 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bjVxN-0003er-Sf for 24326-done@debbugs.gnu.org; Mon, 12 Sep 2016 14:27:52 -0400 Date: Mon, 12 Sep 2016 21:27:40 +0300 Message-Id: <83zind7z37.fsf@gnu.org> From: Eli Zaretskii To: 24326-done@debbugs.gnu.org In-reply-to: <83mvjvbpyk.fsf@gnu.org> (message from Eli Zaretskii on Mon, 29 Aug 2016 17:38:11 +0300) Subject: Re: bug#24326: 25.1; Daemon doesn't exit on Windows if kill-emacs-hook asks a question References: <83shtobthc.fsf@gnu.org> <83mvjvbpyk.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -7.3 (-------) X-Debbugs-Envelope-To: 24326-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -7.3 (-------) > Date: Mon, 29 Aug 2016 17:38:11 +0300 > From: Eli Zaretskii > > 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? No further comments, so I went ahead and pushed this to the master branch, and I'm marking this bug done. From unknown Tue Aug 19 07:27:16 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 11 Oct 2016 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator