From unknown Sat Jun 14 19:43:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#72517: 31.0.50; [PATCH] Close X connection upon deletion of last emacsclient frame Resent-From: Thomas Fitzsimmons Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Aug 2024 00:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 72517 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 72517@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.172307810430919 (code B ref -1); Thu, 08 Aug 2024 00:49:02 +0000 Received: (at submit) by debbugs.gnu.org; 8 Aug 2024 00:48:24 +0000 Received: from localhost ([127.0.0.1]:35235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbrKK-00082c-3p for submit@debbugs.gnu.org; Wed, 07 Aug 2024 20:48:24 -0400 Received: from lists.gnu.org ([209.51.188.17]:40920) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbrKI-00082V-77 for submit@debbugs.gnu.org; Wed, 07 Aug 2024 20:48:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbrJr-0000by-U9 for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2024 20:47:56 -0400 Received: from mail.fitzsim.org ([69.165.165.189]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbrJq-0000xr-7H for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2024 20:47:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fitzsim.org ; s=20220430; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=at2FydhhQMspkVL++4h7z8YcZV3Q6/5JQyfLogKWMVM=; b=RW8ME4M6kKRDtphiRxaEBfJjTO 7EXL66P/zsiWVuYKEgWEcgqlUXBPPb76/U5Q+JXUR0dyqSDI/0WI5/qDrHE69dh8GStLgE7sDT3Tv 1ypbuWH4RVHa24zeSWA4PXJ6rX449/enYiywI+lC3XdUnHBKDv24DQEqPEg0NQe96ew2RO59s/0e0 xoGTaMZ181Ye7gfvsY70ohhzQEz7RgCzP7Qb0SMf6z97UNiA3Nsv9mymmFrgpNTkgaazfioxsai0N ZJW4WLWYWvgf02hAg1BABCrpDmWu7MhieVvec4DSSB2sBg9dScpTH/zD8wxGih9nqROJTB1Szz6N8 DgrNDIvA==; Received: from [192.168.1.1] (helo=localhost.localdomain) by mail.fitzsim.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sbJ07-0010tF-Om for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2024 20:47:51 -0400 From: Thomas Fitzsimmons Date: Wed, 07 Aug 2024 20:47:48 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=69.165.165.189; envelope-from=fitzsim@fitzsim.org; helo=mail.fitzsim.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) 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: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain Hi, The attached patch fixes an issue reported on the mailing list [1]. After quitting a remote "emacsclient -c" frame using C-x 5 0, the SSH session will hang on exit. It is waiting for the X11 display connection to be closed, but Emacs never closes it. I have been using this patch for a few months without issue, with the Lucid toolkit, running "emacsclient -c" over a remote X11 connection. I just retested it on master (423c86cbde7b1ed1d42c7e21fef6e8be872857b0) with "./configure --with-x-toolkit=lucid" and it works for me. I would like others who use remote X11 emacsclient to try the patch, to make sure it does not introduce crashes, error messages or warnings. If it works for others, I can push the patch to master. Thomas 1. https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg00950.html --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Close-X-connection-upon-deletion-of-last-emacsclient.patch >From 27496ab740722d2246ecec1ffbb7f7390d081873 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 7 Aug 2024 19:46:04 -0400 Subject: [PATCH] Close X connection upon deletion of last emacsclient frame This fixes an issue reported on the mailing list: https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg00950.html * lisp/server.el (server-handle-delete-frame): If the frame is an X frame and DISPLAY is set, close the X connection to the display. --- lisp/server.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/server.el b/lisp/server.el index abfd3d4d753..6f39ae651c7 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -510,7 +510,13 @@ server-handle-delete-frame (eq proc (frame-parameter f 'client)))) (frame-list)))) (server-log (format "server-handle-delete-frame, frame %s" frame) proc) - (server-delete-client proc 'noframe)))) ; Let delete-frame delete the frame later. + (server-delete-client proc 'noframe) ; Let delete-frame delete the frame later. + ;; Close the X connection next time the main loop becomes idle. + ;; This prevents an SSH session from hanging after exiting a + ;; remote "emacsclient -c" frame via C-x 5 0. + (let ((display (frame-parameter frame 'display))) + (when (and display (eq (framep frame) 'x)) + (run-at-time nil nil (lambda () (x-close-connection display)))))))) (defun server-handle-suspend-tty (terminal) "Notify the client process that its tty device is suspended." -- 2.39.2 --=-=-=-- From unknown Sat Jun 14 19:43:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#72517: 31.0.50; [PATCH] Close X connection upon deletion of last emacsclient frame Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Aug 2024 05:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72517 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Thomas Fitzsimmons , Po Lu Cc: 72517@debbugs.gnu.org Received: via spool by 72517-submit@debbugs.gnu.org id=B72517.172309502327466 (code B ref 72517); Thu, 08 Aug 2024 05:31:02 +0000 Received: (at 72517) by debbugs.gnu.org; 8 Aug 2024 05:30:23 +0000 Received: from localhost ([127.0.0.1]:35339 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbvjC-00078v-VB for submit@debbugs.gnu.org; Thu, 08 Aug 2024 01:30:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57598) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbvjB-00078g-I3 for 72517@debbugs.gnu.org; Thu, 08 Aug 2024 01:30:22 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbvif-0004AV-LU; Thu, 08 Aug 2024 01:29:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=pFDE8F8K0wwnmJQ4CznBBMzuNdFom7++4KZ7gayrbfU=; b=SaCjEYDCzk3z Cy8cvwPUvI75MrepqNYrM7pEnOegf7x59/zpPzCRkoh5lub2Dpnu23lYXioQxAumO2JFi0Dpw5Svv nArzFLdqZNZbqQYCZKcPQFKKj3O0goWbpVdu2r38ceVtHtrMY4p8sVYrjkBtOpru41CTvMzHLfmcb PBTtDRPwpU92j0xw9VIPZ88uuPDEbTTWVTXJlou9i3ic3yul/fG73WINJrHxErmHhe4PRmYn9T/ZC MjBbg8xUhppDBRSl3MXNbw1z/pjojbBh3rzv1z0DtIYmdgWTjkRqXcqdAJYJJb4N79UmS6X5Us1sE 3q7yTFR1e1fXi6GfLNuaeg==; Date: Thu, 08 Aug 2024 08:29:47 +0300 Message-Id: <86mslnmvjo.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Thomas Fitzsimmons on Wed, 07 Aug 2024 20:47:48 -0400) References: X-Spam-Score: -2.3 (--) 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: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Thomas Fitzsimmons > Date: Wed, 07 Aug 2024 20:47:48 -0400 > > The attached patch fixes an issue reported on the mailing list [1]. > After quitting a remote "emacsclient -c" frame using C-x 5 0, the SSH > session will hang on exit. It is waiting for the X11 display connection > to be closed, but Emacs never closes it. > > I have been using this patch for a few months without issue, with the > Lucid toolkit, running "emacsclient -c" over a remote X11 connection. > > I just retested it on master (423c86cbde7b1ed1d42c7e21fef6e8be872857b0) > with "./configure --with-x-toolkit=lucid" and it works for me. > > I would like others who use remote X11 emacsclient to try the patch, to > make sure it does not introduce crashes, error messages or warnings. If > it works for others, I can push the patch to master. Thanks, but "ssh -X" is not the only way of starting a remote client session, is it? How do we know closing the X connection is TRT in all the cases, and cannot do any harm in some use cases other than yours? I'm also surprised that such a fundamental problem is raised only now, when remote connections existed for decades. Are you saying this is a regression due to some recent change we installed? If not, how come this went undetected for so many years? Po Lu, any comments or suggestions? From unknown Sat Jun 14 19:43:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#72517: 31.0.50; [PATCH] Close X connection upon deletion of last emacsclient frame Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Aug 2024 07:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72517 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: 72517@debbugs.gnu.org, Thomas Fitzsimmons Received: via spool by 72517-submit@debbugs.gnu.org id=B72517.17231018846496 (code B ref 72517); Thu, 08 Aug 2024 07:25:02 +0000 Received: (at 72517) by debbugs.gnu.org; 8 Aug 2024 07:24:44 +0000 Received: from localhost ([127.0.0.1]:35430 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbxVr-0001gh-Rv for submit@debbugs.gnu.org; Thu, 08 Aug 2024 03:24:44 -0400 Received: from sonic302-20.consmr.mail.ne1.yahoo.com ([66.163.186.146]:38005) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbxVp-0001gT-8A for 72517@debbugs.gnu.org; Thu, 08 Aug 2024 03:24:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1723101849; bh=BA/XzxB0luxVLM4p1hFtI0vdjrBZILsXcSgG9hjA4xI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=q4Y5udVG5xnCqqtncuGq3s/GQ4kx4layATHNfDFEWfEgCctaKswEXbhGOHZCdBI1VSIsQeqXLW6nZ5fYKzIJa4yor1IWbg1u2OyJL0CKl42dgRfAvdOBwCfFF0k9W0jPisIyFf4mIiKNHgWHfkql4b3wI4o1nSb7j39XdUy73rVSfMrWUSgal1A7pHj/05QAn6HI+iLlio7V5+pNgiiGH8hNbVqmuxtd69bHyk708ZkKn63QCif98IfRcz68/h5CQL2CYrbN5UyZW1uDLj/yOi2mcFijwHjPmvkQD1nsH2JtKtzoWFkchRZ+3Mu/7KxkKtV4fNuXpewSu56gsXbVyw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1723101849; bh=FCZ7t1myza1pDPzGKV/q32ipxIX7RY0HmKrEKmXwr1Y=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=D9lMwp2qJp4qgNpxa4XHviMog/zdVQY285SKbSPJiJZ8NurKhcpZGnwf4gxx2U+Q3gwK2Go/aC5/RNXxEfOKCsV+wseV+UjeQXZa+Fdrq5hV5RVtaZDDxnrN7kHi1qEUd7r5oBKstn81OZmPo0h9G2mbvzYRL6Itrdg9VcewHH01a7pq5tYBIg+RzsMSfnzUrXMuvGLHcts9ojpEhxTY7fKPG7z1nUA6b624tNN0jIcr4udf07K4unj5//kRwMqPTLnOC87q/hQaJdr/9vQxW0weEfu3Oyg+cZiaUmPy1GvpV5oaCYKttIRc7yE+qh5DA/fRpeVxfXsma2q/nOtC/Q== X-YMail-OSG: Bl_vG7YVM1lbWYbLJyTJ5GLT_9dyZfOcdwxOPqbL80pw81fZaALvlvFmwe7RFzJ K7FOMTP5fK1odsMdVglavnhGRatbiIGVXNv5Jru4eUlFh1sRtMwR.p9Prj6SqpaVK53Z2KX0gIPo bjt80S1DMSTmqokda7TQ9vTvDcf.gpQuGqRMKod_IC_ywhN_u.uxoONP7MF6SQ3_B23kmHXCAHVR WmsAkv8oGLLBkZj.HJmGCHXWA2vVVldQEphjNZhDU45xFAtKl6Shl_6XugsWgYVCUbdn93A0fLYF ytdoUL8y_tr7ib0gSIFqJ.QJCgizkkvMnT4d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r76V.Mfptx90aF_xeBWE0SR5i_E3C3oVTqVK jIql1BXBfSmMr.z4thrAfo8lsqGY5ngzHJ4SAT1Tgiit9qEKxuvb4xu3nGhw0KbiqN6hSGQ8qEVr m_6zDzOIMHPt5AwCh5n1aEJtlVZacRHvG_DMjNBJIaiTlTvUYMVuHzMEMyTZ00erHoX0mVd1GNNZ wYCzjbqGh6OhlsMAP0QqzMPXrk0Hkgv3jxVAamLSFlstSPqeE7oX0mebrY6hqq1RQvCZl8oLom.O ZKMh.LmxvK1rsl0Us.keR2IsF.5vfff56.80jhn8siWkZrnPA3kKJ8NugmAuMFQN9Vujdnij1Hf3 KH8WsDDInChB_C8r0wOfe_BIDJhxph3noevSmQJTS9WcBDiRXPbEpezYwwa.Jiaj.OjByCfPjyHe cM8lIDD807K3B3ohV8fPvH851OReTidCWbdTrhbCk6KjAC9eySgClaBGglGKTM9qS9BfCkwSViQK tVlcBwLWbH8SmTSpXSiC9I48V4VcVFQvFtMqxsvFeKMFbL_5XPoPEoQ2r9bLLYtBrryM2ydFMcZt 7LsIQi.hYE5GJ3vzbXHV_Pm696CzYPwTbKUnibvjNKTa7EWtLqAY5zmWFUz2HhsM7Hj2uPRe9JME _9R_B7_g1pMMtuWGdhtkLnWWBG7Ev3WjHhgaOPvlqDsdVDvq3Zbih9aemQ6kP0mAUVtRdndboddW q58jpYcV3b_sAiKGb2lF5jEyadp8aduuS4U69u9MY100jG6_FYo9RDM9a9zb6zdjsFNpAqDPWtg0 R1pTg8oFFWdwv7O6tr6BmPUOJo3mRtxsmNYLjkLduXyNUzC.ey30hkHrWbhhgoFfykxdB9EOkPMp WBATnil2.h3zeaY2Nmxgcj27ZWmsRFDhLqS3DpSe_zWk0zGSabwdD_p.iTe2yNOUnUPD8Yw-- X-Sonic-MF: X-Sonic-ID: b4672962-da09-4574-bff1-3b307646cd2e Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ne1.yahoo.com with HTTP; Thu, 8 Aug 2024 07:24:09 +0000 Received: by hermes--production-sg3-fc85cddf6-gmtjx (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID e8e42c87f18d8abf3d1fc32367bf7405; Thu, 08 Aug 2024 07:24:04 +0000 (UTC) From: Po Lu In-Reply-To: <86mslnmvjo.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 08 Aug 2024 08:29:47 +0300") References: <86mslnmvjo.fsf@gnu.org> Date: Thu, 08 Aug 2024 15:23:56 +0800 Message-ID: <87mslnmq9f.fsf@yahoo.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.22544 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 1787 X-Spam-Score: 0.0 (/) 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: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> From: Thomas Fitzsimmons >> Date: Wed, 07 Aug 2024 20:47:48 -0400 >> >> The attached patch fixes an issue reported on the mailing list [1]. >> After quitting a remote "emacsclient -c" frame using C-x 5 0, the SSH >> session will hang on exit. It is waiting for the X11 display connection >> to be closed, but Emacs never closes it. >> >> I have been using this patch for a few months without issue, with the >> Lucid toolkit, running "emacsclient -c" over a remote X11 connection. >> >> I just retested it on master (423c86cbde7b1ed1d42c7e21fef6e8be872857b0) >> with "./configure --with-x-toolkit=lucid" and it works for me. >> >> I would like others who use remote X11 emacsclient to try the patch, to >> make sure it does not introduce crashes, error messages or warnings. If >> it works for others, I can push the patch to master. > > Thanks, but "ssh -X" is not the only way of starting a remote client > session, is it? How do we know closing the X connection is TRT in all > the cases, and cannot do any harm in some use cases other than yours? > > I'm also surprised that such a fundamental problem is raised only now, > when remote connections existed for decades. Are you saying this is a > regression due to some recent change we installed? If not, how come > this went undetected for so many years? > > Po Lu, any comments or suggestions? The issue that ought to be fixed is emacsclient's waiting for the display connection to be closed before exiting, as the automatic closure of connections without frames is expressly disabled on X toolkit builds, since closing a display connection is liable to induce crashes in the X toolkit. Unless I misunderstand Thomas and it is ssh that is refusing to exit. From unknown Sat Jun 14 19:43:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#72517: 31.0.50; [PATCH] Close X connection upon deletion of last emacsclient frame Resent-From: Thomas Fitzsimmons Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Aug 2024 08:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72517 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Po Lu Cc: Eli Zaretskii , 72517@debbugs.gnu.org Received: via spool by 72517-submit@debbugs.gnu.org id=B72517.172310744115711 (code B ref 72517); Thu, 08 Aug 2024 08:58:02 +0000 Received: (at 72517) by debbugs.gnu.org; 8 Aug 2024 08:57:21 +0000 Received: from localhost ([127.0.0.1]:35539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbyxU-00045L-Mv for submit@debbugs.gnu.org; Thu, 08 Aug 2024 04:57:21 -0400 Received: from mail.fitzsim.org ([69.165.165.189]:42904) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbyxS-000453-6t for 72517@debbugs.gnu.org; Thu, 08 Aug 2024 04:57:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fitzsim.org ; s=20220430; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=X+aOBgYB2DuSkXwkkNw1YoMsCHrL6xrfcHNo6lyct80=; b=W9hbMy7dxoDbpv1mA54kq0Uxd1 R+FXwXOsScKkGpH0JWgJItUL9Ve/hiEfqqmkhmCVr5jtnczfbchq/KcRBitDrgqlY65yOTRUeUOhh Wm3ZpqHqJcRFpg2x7R5oMIt9IGmF70CLBw6INMhDsm6OgbbpGTbIN+2Bmx90vUDVCYoXRLToW/swP xHMjs9d0zeQygs66qelppZf835WpGkuqECe9d0aQNecvuuP8xCBgUmdrYbQc3eAylcpfN1fIy3Uol jTaYGMToDIsiWFp9W9XCsjntlwgC3aMswZhdZBUK2x970nZ2tiR2jHkcMKW2Aw6ZAwSDpcE6hvag8 IbgOSbNA==; Received: from [192.168.1.1] (helo=localhost.localdomain) by mail.fitzsim.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sbQdG-00115C-Ta; Thu, 08 Aug 2024 04:56:45 -0400 From: Thomas Fitzsimmons In-Reply-To: <87mslnmq9f.fsf@yahoo.com> (Po Lu's message of "Thu, 08 Aug 2024 15:23:56 +0800") References: <86mslnmvjo.fsf@gnu.org> <87mslnmq9f.fsf@yahoo.com> Date: Thu, 08 Aug 2024 04:56:44 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) 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: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Po Lu writes: > Eli Zaretskii writes: > >>> From: Thomas Fitzsimmons >>> Date: Wed, 07 Aug 2024 20:47:48 -0400 >>> >>> The attached patch fixes an issue reported on the mailing list [1]. >>> After quitting a remote "emacsclient -c" frame using C-x 5 0, the SSH >>> session will hang on exit. It is waiting for the X11 display connection >>> to be closed, but Emacs never closes it. >>> >>> I have been using this patch for a few months without issue, with the >>> Lucid toolkit, running "emacsclient -c" over a remote X11 connection. >>> >>> I just retested it on master (423c86cbde7b1ed1d42c7e21fef6e8be872857b0) >>> with "./configure --with-x-toolkit=lucid" and it works for me. >>> >>> I would like others who use remote X11 emacsclient to try the patch, to >>> make sure it does not introduce crashes, error messages or warnings. If >>> it works for others, I can push the patch to master. >> >> Thanks, but "ssh -X" is not the only way of starting a remote client >> session, is it? How do we know closing the X connection is TRT in all >> the cases, and cannot do any harm in some use cases other than yours? >> >> I'm also surprised that such a fundamental problem is raised only now, >> when remote connections existed for decades. Are you saying this is a >> regression due to some recent change we installed? If not, how come >> this went undetected for so many years? >> >> Po Lu, any comments or suggestions? > > The issue that ought to be fixed is emacsclient's waiting for the > display connection to be closed before exiting, as the automatic closure > of connections without frames is expressly disabled on X toolkit builds, > since closing a display connection is liable to induce crashes in the X > toolkit. Unless I misunderstand Thomas and it is ssh that is refusing > to exit. Thank you for taking a look at this. It is indeed SSH that is refusing to exit. i.e., after exiting the emacsclient frame, I am returned to the remote SSH shell. Pressing control-d in that shell does not return me back to my local shell (the shell from which I SSH'd). I have to press control-c and then I am returned back to my local shell. Nothing emacs-related is hanging; the emacs daemon continues running, and I can re-SSH and re-run emacsclient. So the control-c to exit the SSH session does not seem to destabilize the emacs daemon. (However, I suspect the control-c is severing the X display connection which seems less safe and potentially more subject to race conditions than Emacs itself closing the X connection.) There are so many use cases for emacsclient that any patch seems risky, which is why I filed this bug report with something that works for me. If there is a comprehensive set of emacsclient connection/disconnection tests, and/or any verbosity/debugging options that might help, then I can run them by hand on my setup. I did try: 1. local X11 "emacsclient -c -s test" 2. local X11 "emacsclient -nw -s test" 3. remote (over ssh -X) "emacsclient -c -s test" 4. remote (over ssh -X) "emacsclient -nw -s test" against "emacs -Q --fg-daemon=test". In each case, with this patch, the key sequence C-x 5 0 exits the frame without issue, and (for tests 3 and 4) C-d exits the SSH session (returns me to my local shell) without my having to press C-c. Without my patch, test 3 does result in SSH refusing to exit. And, even with my patch, for test case 3, using C-x C-c to delete the frame still results in SSH refusing to exit. (It would be nice to fix this case too, but I always use C-x 5 0, so I wanted to start by trying to fix it.) Thomas From unknown Sat Jun 14 19:43:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#72517: 31.0.50; [PATCH] Close X connection upon deletion of last emacsclient frame Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Aug 2024 09:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72517 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Thomas Fitzsimmons Cc: Eli Zaretskii , 72517@debbugs.gnu.org Received: via spool by 72517-submit@debbugs.gnu.org id=B72517.172310897618289 (code B ref 72517); Thu, 08 Aug 2024 09:23:02 +0000 Received: (at 72517) by debbugs.gnu.org; 8 Aug 2024 09:22:56 +0000 Received: from localhost ([127.0.0.1]:35574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbzMF-0004ku-PE for submit@debbugs.gnu.org; Thu, 08 Aug 2024 05:22:56 -0400 Received: from sonic305-20.consmr.mail.ne1.yahoo.com ([66.163.185.146]:44930) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbzMD-0004kf-It for 72517@debbugs.gnu.org; Thu, 08 Aug 2024 05:22:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1723108940; bh=UPW52hkxpukCR49JnRCDUDeQBQ6o7oobttyMsZ3c8Ro=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=MiA+MCCq4oujwU44Xsprocp5Ern+Ni0lLBQfNDFBXBq41ITUZYe77SrowujwmDRE42MgwCz8XCMVyYeDw1hePpy42qhKjJ5XbNhXF+i2ya6dUr3GUILrv5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H6dPuPA2U_HIkSMyWcaK1rV_5 gGtpAyE9Il6lKTn5Xg.RFFZmiqeTIneFF.YZNfRdDw8lt5t1R9SPwbBM1LaKZjSTtvrgcTe5VX7M h8kx_r5vrEikKOSUpcFOA.eCYFL948rB5wtzfKWPOnxeLITpWKHuzIYcmeEglr14si_dq7v529KM yq7NRfxhRYmmnzC0RQnKRne56fW8wORlRcvLM89lGbQFmPfiLvfQvEr0V.tzIN535hXXUzX84.ke xsk5k_61EzpuZW7uyEAabpAoXBIWiNY822Lys4miVXSMuLIwAg4SGarQ0VHwUeocfUM8irVYvBIR BQNjKp727fcME2CV6iVUs9acd1XK_2rgXn6XyiEZtmKdPNLUZ7aEf9IRc07T.QisJcgtKpi9BWy. V1oavkC1fmkI0oXcC7TML6zdMGfkTgZKA_LkfAyDWZ5eSHX5BoW9eXimWjt6OYksX2kae2aYBVJE Z_HYTLQeMsiLSlmJCgcqWKrXEnFBk3l88gDYwlC9Kcn.suuYMcyw_xl.mMQ7aX8dbzGyETkyGZAK TjcZ.93jcJa9SSIXjyKUI1I.7BCQfGl5D7IWsQZMJHsfAhS9j9zW2kjldP5r_MX8W5EdVkbyVOpV gkRWL6DYVszESlV13wRNYhQdR1TDf.O5nBJlL3km3NTkVuCqrXyzKfdHviXAFZ61I7BPLPrP7M6W vSHlo1QlozMUUbF_Rne8L7HSfHtMbCn714CQyMhctC2ySCkcTNTJ0vNTyCETixaKLWFn5aUbhvNb BcNtIgHjwh.2dKXMA_R2RhKnturklgG1PxCbFwc3NzPjzhJXYyKe62QW1D3YvNdAxC6sJzjNuPZ6 51ne2dkt_d3pIEBHhsDyOXRIKduMKbBIf6MDfKz15HJhpIi8sNCmwo29PLCHlGg3aZBfz0g-- X-Sonic-MF: X-Sonic-ID: 47cdbb24-6e37-455f-bd1b-e5caeb7f9c6c Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.ne1.yahoo.com with HTTP; Thu, 8 Aug 2024 09:22:20 +0000 Received: by hermes--production-sg3-fc85cddf6-bk4qn (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 03b32c4ebcaded34e4ba38ea72bfeab9; Thu, 08 Aug 2024 09:22:14 +0000 (UTC) From: Po Lu In-Reply-To: (Thomas Fitzsimmons's message of "Thu, 08 Aug 2024 04:56:44 -0400") References: <86mslnmvjo.fsf@gnu.org> <87mslnmq9f.fsf@yahoo.com> Date: Thu, 08 Aug 2024 17:22:00 +0800 Message-ID: <87frrfmksn.fsf@yahoo.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.22544 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 2038 X-Spam-Score: 0.0 (/) 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: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Thomas Fitzsimmons writes: > Thank you for taking a look at this. > > It is indeed SSH that is refusing to exit. > > i.e., after exiting the emacsclient frame, I am returned to the remote > SSH shell. Pressing control-d in that shell does not return me back to > my local shell (the shell from which I SSH'd). I have to press > control-c and then I am returned back to my local shell. > > Nothing emacs-related is hanging; the emacs daemon continues running, > and I can re-SSH and re-run emacsclient. So the control-c to exit the > SSH session does not seem to destabilize the emacs daemon. (However, I > suspect the control-c is severing the X display connection which seems > less safe and potentially more subject to race conditions than Emacs > itself closing the X connection.) > > There are so many use cases for emacsclient that any patch seems risky, > which is why I filed this bug report with something that works for me. > > If there is a comprehensive set of emacsclient connection/disconnection > tests, and/or any verbosity/debugging options that might help, then I > can run them by hand on my setup. I did try: > > 1. local X11 "emacsclient -c -s test" > 2. local X11 "emacsclient -nw -s test" > 3. remote (over ssh -X) "emacsclient -c -s test" > 4. remote (over ssh -X) "emacsclient -nw -s test" > > against "emacs -Q --fg-daemon=test". In each case, with this patch, the > key sequence C-x 5 0 exits the frame without issue, and (for tests 3 and > 4) C-d exits the SSH session (returns me to my local shell) without my > having to press C-c. Without my patch, test 3 does result in SSH > refusing to exit. > > And, even with my patch, for test case 3, using C-x C-c to delete the > frame still results in SSH refusing to exit. (It would be nice to fix > this case too, but I always use C-x 5 0, so I wanted to start by trying > to fix it.) > > Thomas I suggest configuring Emacs with --with-x-toolkit=no (as is recommended for users who connect to remote display servers to begin with). From unknown Sat Jun 14 19:43:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#72517: 31.0.50; [PATCH] Close X connection upon deletion of last emacsclient frame Resent-From: Thomas Fitzsimmons Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Aug 2024 10:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72517 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Po Lu Cc: Eli Zaretskii , 72517@debbugs.gnu.org Received: via spool by 72517-submit@debbugs.gnu.org id=B72517.172311178423015 (code B ref 72517); Thu, 08 Aug 2024 10:10:01 +0000 Received: (at 72517) by debbugs.gnu.org; 8 Aug 2024 10:09:44 +0000 Received: from localhost ([127.0.0.1]:35635 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sc05Y-0005z8-3V for submit@debbugs.gnu.org; Thu, 08 Aug 2024 06:09:44 -0400 Received: from mail.fitzsim.org ([69.165.165.189]:59162) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sc05W-0005yt-MN for 72517@debbugs.gnu.org; Thu, 08 Aug 2024 06:09:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fitzsim.org ; s=20220430; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0Yn+RwjkapXvVU8JXZwAXdXD/Dv+z125e27w7nce7mg=; b=i5/hyZAirC0bxfVIcS67WrJ0m2 pOGemxHmpYILOWCeSo27ivdafpD2N+r17ymbnXxgIjg5taOtm2frPjM1WBDolPFzpEgDC5Lh4gLSH exj3RlaOWBWNOKRIrXQc8jJ2poE9cOZo4luZ3vlE0fS1IB92+HFyhJoknVY2DXIcg7vc+Wn33GM0I 5XpjNk3KZ407A7iTI2PRewY6XC+/XAziupdSS6/Ze5mC7G4bLhRhNqF5z5HtXD15BIDfY1JWP18rh 31q3i6A9OjWYUTAhMY60zb+TXISFX5Wl1U1l/IvzKPUGadaJS0P5DdsD/DZIIKKNEfh3qI0H2BEV/ 51Risoeg==; Received: from [192.168.1.1] (helo=localhost.localdomain) by mail.fitzsim.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sbRlH-00117u-Jn; Thu, 08 Aug 2024 06:09:09 -0400 From: Thomas Fitzsimmons In-Reply-To: <87frrfmksn.fsf@yahoo.com> (Po Lu's message of "Thu, 08 Aug 2024 17:22:00 +0800") References: <86mslnmvjo.fsf@gnu.org> <87mslnmq9f.fsf@yahoo.com> <87frrfmksn.fsf@yahoo.com> Date: Thu, 08 Aug 2024 06:09:05 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) 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: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Po Lu writes: > Thomas Fitzsimmons writes: > >> Thank you for taking a look at this. >> >> It is indeed SSH that is refusing to exit. >> >> i.e., after exiting the emacsclient frame, I am returned to the remote >> SSH shell. Pressing control-d in that shell does not return me back to >> my local shell (the shell from which I SSH'd). I have to press >> control-c and then I am returned back to my local shell. >> >> Nothing emacs-related is hanging; the emacs daemon continues running, >> and I can re-SSH and re-run emacsclient. So the control-c to exit the >> SSH session does not seem to destabilize the emacs daemon. (However, I >> suspect the control-c is severing the X display connection which seems >> less safe and potentially more subject to race conditions than Emacs >> itself closing the X connection.) >> >> There are so many use cases for emacsclient that any patch seems risky, >> which is why I filed this bug report with something that works for me. >> >> If there is a comprehensive set of emacsclient connection/disconnection >> tests, and/or any verbosity/debugging options that might help, then I >> can run them by hand on my setup. I did try: >> >> 1. local X11 "emacsclient -c -s test" >> 2. local X11 "emacsclient -nw -s test" >> 3. remote (over ssh -X) "emacsclient -c -s test" >> 4. remote (over ssh -X) "emacsclient -nw -s test" >> >> against "emacs -Q --fg-daemon=test". In each case, with this patch, the >> key sequence C-x 5 0 exits the frame without issue, and (for tests 3 and >> 4) C-d exits the SSH session (returns me to my local shell) without my >> having to press C-c. Without my patch, test 3 does result in SSH >> refusing to exit. >> >> And, even with my patch, for test case 3, using C-x C-c to delete the >> frame still results in SSH refusing to exit. (It would be nice to fix >> this case too, but I always use C-x 5 0, so I wanted to start by trying >> to fix it.) >> >> Thomas > > I suggest configuring Emacs with --with-x-toolkit=no (as is recommended > for users who connect to remote display servers to begin with). That works, both C-x C-c and C-x 5 0 exit the emacsclient frame, and SSH does not hang/refuse to exit in either case. I will use --with-x-toolkit=no from now on, thank you! Somehow I missed that recommendation (maybe you can point me to it?). I have always avoided GTK for "emacsclient reasons" but I thought Lucid would be OK. Can I add something like the attached to etc/PROBLEMS? Thanks, Thomas --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=emacsclient-ssh-hang-problems.patch diff --git a/etc/PROBLEMS b/etc/PROBLEMS index 7d7c9ab5f27..d0d529adb3c 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS @@ -178,6 +178,21 @@ The relevant bug report is here: A workaround is to set XLIB_SKIP_ARGB_VISUALS=1 in the environment before starting Emacs, or run Emacs as root. +** emacsclient -c causes an ssh -X session to hang on exit. + +When Emacs is configured with an X toolkit, for example, +--with-x-toolkit=lucid, and emacsclient is run over an "ssh -X" +connection, deleting the emacsclient frame (via C-x 5 0 or C-x C-c) can +leave the X display connection open. + +The symptom is that after you delete the "emacsclient -c" frame, and +then attempt to exit ssh (with C-d, or "exit"), ssh will hang before +returning you to the local shell. You will have to press C-c (to sever +the X connection) before ssh returns you to your local shell (that is, +the shell in which you invoked "ssh -X"). + +To avoid this issue configure Emacs with --with-x-toolkit=no. + ** Emacs built with xwidgets aborts when displaying WebKit xwidgets This happens, for example, when 'M-x xwidget-webkit-browse-url' --=-=-=-- From unknown Sat Jun 14 19:43:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#72517: 31.0.50; [PATCH] Close X connection upon deletion of last emacsclient frame Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Aug 2024 10:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72517 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Thomas Fitzsimmons Cc: luangruo@yahoo.com, 72517@debbugs.gnu.org Received: via spool by 72517-submit@debbugs.gnu.org id=B72517.172311271724584 (code B ref 72517); Thu, 08 Aug 2024 10:26:02 +0000 Received: (at 72517) by debbugs.gnu.org; 8 Aug 2024 10:25:17 +0000 Received: from localhost ([127.0.0.1]:35657 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sc0Kb-0006OR-Cj for submit@debbugs.gnu.org; Thu, 08 Aug 2024 06:25:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43444) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sc0KZ-0006O7-0z for 72517@debbugs.gnu.org; Thu, 08 Aug 2024 06:25:15 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sc0K0-00048L-S5; Thu, 08 Aug 2024 06:24:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=rJk+89UszK+bfN+smDLkap49GoH/EgTjgoQ/pijJB9E=; b=HeL6qiiEL2EJ 0+eWtaH/0M28l/0vo++Uz77cxT/gJOWiADfnedIxwU7j2wG1SLCx2M+0alcI5RzjUFQj6B0UbOWJa ngreFSlM8KlOuJRmlse9kIS/nEs3Vg40SMos/1oKC9VNuCLAzqNRgwNCCpwOG4x3kAbBRsS5s2HBT I4WG6HKbGa94gOLEU3JvoKcg5Yur2PDuLDFNPtUvA7pSiA2ca9xE9Idi4hRFX/CaRLeOyzmNqSeuc gumsZAJwGf9NjaxE68o4cm4Mavpv3jqSzzprYyeUowAL5kiC6o07DLhYFtVLsQeriAPz68oANuUIH neVF+CIlweWcdRjrNxwb7A==; Date: Thu, 08 Aug 2024 13:24:38 +0300 Message-Id: <86ed6zmhw9.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Thomas Fitzsimmons on Thu, 08 Aug 2024 06:09:05 -0400) References: <86mslnmvjo.fsf@gnu.org> <87mslnmq9f.fsf@yahoo.com> <87frrfmksn.fsf@yahoo.com> X-Spam-Score: -2.3 (--) 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: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Thomas Fitzsimmons > Cc: Eli Zaretskii , 72517@debbugs.gnu.org > Date: Thu, 08 Aug 2024 06:09:05 -0400 > > Can I add something like the attached to etc/PROBLEMS? SGTM, just be sure to mention this bug in the log message when you install this. Thanks. From unknown Sat Jun 14 19:43:56 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Thomas Fitzsimmons Subject: bug#72517: closed (Re: bug#72517: 31.0.50; [PATCH] Close X connection upon deletion of last emacsclient frame) Message-ID: References: X-Gnu-PR-Message: they-closed 72517 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 72517@debbugs.gnu.org Date: Fri, 09 Aug 2024 03:03:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1723172582-30479-1" This is a multi-part message in MIME format... ------------=_1723172582-30479-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #72517: 31.0.50; [PATCH] Close X connection upon deletion of last emacsclie= nt frame which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 72517@debbugs.gnu.org. --=20 72517: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D72517 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1723172582-30479-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 72517-done) by debbugs.gnu.org; 9 Aug 2024 03:02:23 +0000 Received: from localhost ([127.0.0.1]:37358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1scFtW-0007uK-TG for submit@debbugs.gnu.org; Thu, 08 Aug 2024 23:02:23 -0400 Received: from mail.fitzsim.org ([69.165.165.189]:36378) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1scFtU-0007u6-KN for 72517-done@debbugs.gnu.org; Thu, 08 Aug 2024 23:02:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fitzsim.org ; s=20220430; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=vvmmNfBK+nOqg13FJ4DwFXFFGXBBl0aS1fIe8jsFUqM=; b=TZK/qw5hJgkfkh7c2Br8rcfDyM lXF1saCD0lpQE75eRLOPg6oH4f31EqqGRrj6iZnZk95reHP4SMlbMjjTWmLtFPeQ4CP/dlXJvu5Jx e5N0HxlcyhJ7FJHYIzHPoJZt/8TtMAPasbs7h73M3fY9Uh5s1YHOKpiBNoxnQp3mpY0Z8+HqlCDWT IBclSxVhtRUwrsJ/BEhYb1yR/mJKYsSwc31tlTRMMqQ+0pUCHhTY1ha6konZyuCsz4zWtxZcrVyPn VGgVIlDJcy6D5KCPK2J2UW6pXqbeAP+5QX/7IUMxfebqISbqAAkyiDsdjz46qycfnQ9c/VP/9HAlF IqJVsLoA==; Received: from [192.168.1.1] (helo=localhost.localdomain) by mail.fitzsim.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sbhZH-0011WS-TB; Thu, 08 Aug 2024 23:01:46 -0400 From: Thomas Fitzsimmons To: Eli Zaretskii Subject: Re: bug#72517: 31.0.50; [PATCH] Close X connection upon deletion of last emacsclient frame In-Reply-To: <86ed6zmhw9.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 08 Aug 2024 13:24:38 +0300") References: <86mslnmvjo.fsf@gnu.org> <87mslnmq9f.fsf@yahoo.com> <87frrfmksn.fsf@yahoo.com> <86ed6zmhw9.fsf@gnu.org> Date: Thu, 08 Aug 2024 23:01:45 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 72517-done Cc: luangruo@yahoo.com, 72517-done@debbugs.gnu.org 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: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> From: Thomas Fitzsimmons >> Cc: Eli Zaretskii , 72517@debbugs.gnu.org >> Date: Thu, 08 Aug 2024 06:09:05 -0400 >> >> Can I add something like the attached to etc/PROBLEMS? > > SGTM, just be sure to mention this bug in the log message when you > install this. Done. Thanks, Thomas ------------=_1723172582-30479-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 8 Aug 2024 00:48:24 +0000 Received: from localhost ([127.0.0.1]:35235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbrKK-00082c-3p for submit@debbugs.gnu.org; Wed, 07 Aug 2024 20:48:24 -0400 Received: from lists.gnu.org ([209.51.188.17]:40920) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sbrKI-00082V-77 for submit@debbugs.gnu.org; Wed, 07 Aug 2024 20:48:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbrJr-0000by-U9 for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2024 20:47:56 -0400 Received: from mail.fitzsim.org ([69.165.165.189]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbrJq-0000xr-7H for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2024 20:47:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fitzsim.org ; s=20220430; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=at2FydhhQMspkVL++4h7z8YcZV3Q6/5JQyfLogKWMVM=; b=RW8ME4M6kKRDtphiRxaEBfJjTO 7EXL66P/zsiWVuYKEgWEcgqlUXBPPb76/U5Q+JXUR0dyqSDI/0WI5/qDrHE69dh8GStLgE7sDT3Tv 1ypbuWH4RVHa24zeSWA4PXJ6rX449/enYiywI+lC3XdUnHBKDv24DQEqPEg0NQe96ew2RO59s/0e0 xoGTaMZ181Ye7gfvsY70ohhzQEz7RgCzP7Qb0SMf6z97UNiA3Nsv9mymmFrgpNTkgaazfioxsai0N ZJW4WLWYWvgf02hAg1BABCrpDmWu7MhieVvec4DSSB2sBg9dScpTH/zD8wxGih9nqROJTB1Szz6N8 DgrNDIvA==; Received: from [192.168.1.1] (helo=localhost.localdomain) by mail.fitzsim.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sbJ07-0010tF-Om for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2024 20:47:51 -0400 From: Thomas Fitzsimmons To: bug-gnu-emacs@gnu.org Subject: 31.0.50; [PATCH] Close X connection upon deletion of last emacsclient frame Date: Wed, 07 Aug 2024 20:47:48 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=69.165.165.189; envelope-from=fitzsim@fitzsim.org; helo=mail.fitzsim.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) 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: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain Hi, The attached patch fixes an issue reported on the mailing list [1]. After quitting a remote "emacsclient -c" frame using C-x 5 0, the SSH session will hang on exit. It is waiting for the X11 display connection to be closed, but Emacs never closes it. I have been using this patch for a few months without issue, with the Lucid toolkit, running "emacsclient -c" over a remote X11 connection. I just retested it on master (423c86cbde7b1ed1d42c7e21fef6e8be872857b0) with "./configure --with-x-toolkit=lucid" and it works for me. I would like others who use remote X11 emacsclient to try the patch, to make sure it does not introduce crashes, error messages or warnings. If it works for others, I can push the patch to master. Thomas 1. https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg00950.html --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Close-X-connection-upon-deletion-of-last-emacsclient.patch >From 27496ab740722d2246ecec1ffbb7f7390d081873 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 7 Aug 2024 19:46:04 -0400 Subject: [PATCH] Close X connection upon deletion of last emacsclient frame This fixes an issue reported on the mailing list: https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg00950.html * lisp/server.el (server-handle-delete-frame): If the frame is an X frame and DISPLAY is set, close the X connection to the display. --- lisp/server.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/server.el b/lisp/server.el index abfd3d4d753..6f39ae651c7 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -510,7 +510,13 @@ server-handle-delete-frame (eq proc (frame-parameter f 'client)))) (frame-list)))) (server-log (format "server-handle-delete-frame, frame %s" frame) proc) - (server-delete-client proc 'noframe)))) ; Let delete-frame delete the frame later. + (server-delete-client proc 'noframe) ; Let delete-frame delete the frame later. + ;; Close the X connection next time the main loop becomes idle. + ;; This prevents an SSH session from hanging after exiting a + ;; remote "emacsclient -c" frame via C-x 5 0. + (let ((display (frame-parameter frame 'display))) + (when (and display (eq (framep frame) 'x)) + (run-at-time nil nil (lambda () (x-close-connection display)))))))) (defun server-handle-suspend-tty (terminal) "Notify the client process that its tty device is suspended." -- 2.39.2 --=-=-=-- ------------=_1723172582-30479-1--