From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thomas Fitzsimmons Newsgroups: gmane.emacs.bugs Subject: bug#72517: 31.0.50; [PATCH] Close X connection upon deletion of last emacsclient frame Date: Wed, 07 Aug 2024 20:47:48 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14704"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 72517@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 08 02:48:58 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sbrKq-0003eW-KD for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Aug 2024 02:48:57 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbrKY-0000gg-VO; Wed, 07 Aug 2024 20:48:39 -0400 Original-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 1sbrKX-0000gI-7y for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2024 20:48:37 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sbrKW-00015t-SD for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2024 20:48:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=at2FydhhQMspkVL++4h7z8YcZV3Q6/5JQyfLogKWMVM=; b=HU8Tabaei9egvyhCPDjEqspzwSDJTwIKqRV1j5tKsaUmHL9zdM8u2UKTIWDDir2oQ1I0o1rSfGlX090Gxec/E+HVsazVqDAOpsFMpzu9OXfxT3rHB5TgyTr2xfbL42r8X1dphzSBPD534X8bypVfuTt9Yaz3ikc6qpYNKWy3xLeViJQz4AXf53Ot7D0MoMrMwo99kiJWDlB6ZSCJlfjn5FN/48sM/P1ML6WuBDUUYECOwrWRCKBxXk02thgcd020oJ8Dz7wHLyqbO1ytYU/47qwRNaZp+UG4Kp84JRZurbmWSBQ8JMOOsUPe3HZpz1609X+FpFLHTjsicQvasfCMIQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sbrKw-00083U-B0 for bug-gnu-emacs@gnu.org; Wed, 07 Aug 2024 20:49:02 -0400 X-Loop: help-debbugs@gnu.org 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 X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.172307810430919 (code B ref -1); Thu, 08 Aug 2024 00:49:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Aug 2024 00:48:24 +0000 Original-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 Original-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 Original-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 Original-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==; Original-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 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:289908 Archived-At: --=-=-= 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 --=-=-=--