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: Thu, 08 Aug 2024 04:56:44 -0400 Message-ID: References: <86mslnmvjo.fsf@gnu.org> <87mslnmq9f.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37747"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , 72517@debbugs.gnu.org To: Po Lu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 08 10:58:04 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 1sbyyA-0009YQ-P9 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Aug 2024 10:58:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbyxn-0000st-Pz; Thu, 08 Aug 2024 04:57: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 1sbyxl-0000sU-Kt for bug-gnu-emacs@gnu.org; Thu, 08 Aug 2024 04:57: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 1sbyxl-0008Tm-Ay for bug-gnu-emacs@gnu.org; Thu, 08 Aug 2024 04:57:37 -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:References:In-Reply-To:From:To:Subject; bh=X+aOBgYB2DuSkXwkkNw1YoMsCHrL6xrfcHNo6lyct80=; b=kiMeh8umkVthFP9lWW9Psb8cXzRe0ssUfXqDJDDLvrUjbgvm0fooqexZ1O74xnFrdnK9zk7LuyfUT6DIMuYUi7tUFHMLSaBRhKrc+6O8Zye2rIAT2wZx7EI6KSO0gEdlhBB52Ggi8Krw9Ceh/es4VYc9rdba975ImRmz+bfgfeGKpxH/4xHn3g8dJW7VDAfUt/iDiV0WiR+tntisSbN+A4L88mqAGgvAp86mASK0PyMGmslgWxec0mi/1Z/eB6QnpueREGNylWVqn/1JWxaylbe4OZT8jSBcoN4RjGFwWmzXBJKK+rOn0FzdsWoq/57BsGmpCePToi25RHbjlbUQiA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sbyyA-00046X-Ik for bug-gnu-emacs@gnu.org; Thu, 08 Aug 2024 04:58: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 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 Original-Received: via spool by 72517-submit@debbugs.gnu.org id=B72517.172310744115711 (code B ref 72517); Thu, 08 Aug 2024 08:58:02 +0000 Original-Received: (at 72517) by debbugs.gnu.org; 8 Aug 2024 08:57:21 +0000 Original-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 Original-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==; 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 1sbQdG-00115C-Ta; Thu, 08 Aug 2024 04:56:45 -0400 In-Reply-To: <87mslnmq9f.fsf@yahoo.com> (Po Lu's message of "Thu, 08 Aug 2024 15:23:56 +0800") 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:289926 Archived-At: 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