From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?Adam_Sj=C3=83=C2=B8gren_via_=22Emacs_development_discussions=2E?= Newsgroups: gmane.emacs.devel Subject: Re: Log out hanging after X-forwarded emacsclient Date: Sun, 10 May 2020 12:11:04 +0200 Organization: koldfront - analysis & revolution, Copenhagen, Denmark Message-ID: <87wo5kumkn.fsf_-_@tullinup.koldfront.dk> References: <83zhbcg6s4.fsf@gnu.org> <87r1wng2ki.fsf@linaro.org> <83o8rrenn1.fsf@gnu.org> <87blnr6uck.fsf@tullinup.koldfront.dk> Reply-To: =?UTF-8?Q?Reply-to=3A_Adam_Sj=C3=83=C2=B8gren_=3Casjo=40koldfront=2Edk=3E?= =?UTF-8?Q?=0A?= Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="21460"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: emacs-devel@gnu.org Cancel-Lock: sha1:BsSqKdUnl5/CHJFMfFIsZ9hPSYU= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 10 12:12:04 2020 Return-path: Envelope-to: ged-emacs-devel@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 1jXiwG-0005Vu-LM for ged-emacs-devel@m.gmane-mx.org; Sun, 10 May 2020 12:12:04 +0200 Original-Received: from localhost ([::1]:40614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXiwF-0008D1-No for ged-emacs-devel@m.gmane-mx.org; Sun, 10 May 2020 06:12:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXivU-0007cM-D8 for emacs-devel@gnu.org; Sun, 10 May 2020 06:11:16 -0400 Original-Received: from ciao.gmane.io ([159.69.161.202]:50354) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXivR-0002ic-Pn for emacs-devel@gnu.org; Sun, 10 May 2020 06:11:16 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jXivO-0004ew-M9 for emacs-devel@gnu.org; Sun, 10 May 2020 12:11:10 +0200 X-Injected-Via-Gmane: http://gmane.org/ OpenPGP: id=476630590A231909B0A0961A49D0746121BDE416; url=https://asjo.koldfront.dk/gpg.asc X-Now-Playing: Studier af skyer, =?utf-8?Q?H=C3=A5rdnakket?= Idyl (Olesen-Olesen) X-Face: )qY&CseJ?.:=8F#^~GcSA?F=9eu'{KAFfL1C3/A&:nE?PW\i65"ba0NS)97, Q(^@xk}n4Ou rPuR#V8I(J_@~H($[ym:`K_+]*kjvW>xH5jbgLBVFGXY:(#4P>zVBklLbdL&XxL\M)%T}3S/IS9lMJ ^St'=VZBR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:249644 Archived-At: I wrote: > When I then end emacsclient with C-x # I'm back at the prompt. If I run > "exit", the prompt is hanging, where I would expect to be logged out of > machine1 and returned to machine2. Only after I press control-c do I get > the prompt back: I spent last night tracking this down. The reason one has to press ^C to stop ssh is that Emacs keeps the X-connection open. It is not a bug in ssh, as far as I can tell. This comment in src/xterm.c is no longer accurate: 13402 /* This function is called when the last frame on a display is deleted. */ 13403 void 13404 x_delete_terminal (struct terminal *terminal) 13405 { It doesn't get called when the last frame on a remote display is closed, it is only called when the X connection is severed (i.e. by killing ssh). The reason is found in src/frame.c: 2141 /* If needed, delete the terminal that this frame was on. 2142 (This must be done after the frame is killed.) */ 2143 terminal->reference_count--; 2144 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) 2145 /* FIXME: Deleting the terminal crashes emacs because of a GTK 2146 bug. 2147 https://lists.gnu.org/r/emacs-devel/2011-10/msg00363.html */ 2148 2149 /* Since a similar behavior was observed on the Lucid and Motif 2150 builds (see Bug#5802, Bug#21509, Bug#23499, Bug#27816), we now 2151 don't delete the terminal for these builds either. */ 2152 if (terminal->reference_count == 0 && terminal->type == output_x_window) 2153 terminal->reference_count = 1; 2154 #endif /* USE_X_TOOLKIT || USE_GTK */ With this Emacs doesn't actually call x_delete_terminal() when the last frame on a display is closed, but rather waits until the X connection disappears. If I remove those two lines, a build with GTK crashes immediately when the last frame on a remove display is closed (on purpose, to avoid the endless warnings from Glib - "the GTK bug"), rather than when the X connection is cut. However, I can't reproduce the problem when I build Emacs with Lucid. Closing all frames on a remote display doesn't result in a crash with Lucid - and the prompt/ssh isn't hanging with L2152-2153 removed. So a step towards fixing the GTK problem is to figure out whether the "workaround" in src/frame.c is still needed for Lucid and Motif. Ah, I've now read through the bugs referenced in the comment, and it sounds like the problem that was handled by adding this doesn't happen every time. When x_delete_terminal() gets called much less, the described crashes are less likely to happen. I guess it could be #ifdef'ed again, if the GTK problem is fixed. Hm, ok. I just thought I would follow up on my question. Best regards, Adam -- "Kom låna törnekronan min Adam Sjøgren Lid för konsten eller brinn" asjo@koldfront.dk