emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Log out hanging after X-forwarded emacsclient


From: Adam Sjøgren
Subject: Re: Log out hanging after X-forwarded emacsclient
Date: Sun, 10 May 2020 12:11:04 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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"                         address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]