3

I'm trying to figure out why it is that ssh hangs on exit if, and only if, I login with the -X option and run X11 programs. I found a thread on Google groups which hints to the problem. Stuart Barkley, tells the OP to debug/diagnose using the ~# command to ssh. I found this escape character listed in the manual page. However, as the supplied link demonstrates, it doesn't explain to me what it is I'm seeing. I kinda get it but I'm not sure what to make of it.

There's definitely some lingering X11 sockets that are listening and the ssh session is waiting for them to close. How do I use this information from ~# to trace back to what these really are? Secondly, how do I close these sockets. Below demonstrates what I'm seeing:

# This ssh session started with ssh hercules -X

[afalanga@hercules ~]$ ~#
The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 fd 4/5 cc -1)

[afalanga@hercules ~]$ gvim
[afalanga@hercules ~]$ ~#
The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 fd 4/5 cc -1)
  #1 x11 (t4 r3 i0/0 o0/0 fd 7/7 cc -1)
  #2 x11 (t4 r4 i0/0 o0/0 fd 8/8 cc -1)
  #3 x11 (t4 r5 i0/0 o0/0 fd 9/9 cc -1)

[afalanga@hercules ~]$ gvim 
[afalanga@hercules ~]$ ~#
The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 fd 4/5 cc -1)
  #1 x11 (t4 r3 i0/0 o0/0 fd 7/7 cc -1)
  #2 x11 (t4 r4 i0/0 o0/0 fd 8/8 cc -1)
  #3 x11 (t4 r5 i0/0 o0/0 fd 9/9 cc -1)
  #4 x11 (t4 r6 i0/0 o0/0 fd 10/10 cc -1)

[afalanga@hercules ~]$ ~#
The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 fd 4/5 cc -1)
  #2 x11 (t4 r4 i0/0 o0/0 fd 8/8 cc -1)
  #3 x11 (t4 r5 i0/0 o0/0 fd 9/9 cc -1)

The first call to ~# is before starting any X programs on the ssh session. As you can see, there is only one open socket. The second call to ~# is after opening the first gvim at which point there are 4 open sockets. After opening a second gvim, there are 5. When I close both gvim windows, there remain 2 X11 sockets.

1 Answer 1

2

How do I use this information from ~# to trace back to what these really are?

The output informs you about existing connections between your client and your server. In the first place, there is only session, then you opened gvim, which led to allocation of 3 channels, another gvim allocated another channel, but they are leaving some behind.

Secondly, how do I close these sockets.

By typing Ctrl+C or ~.. It is the behaviour (feature, improvement, or you name it) of the gvim. It opens connection to X server to update the window title and X clipboard, as gvim manual page says (and does not close it to make the next start faster as I understand it). You can get rid of this behaviour using -X switch to gvim:

-X

Don't connect to the X server. Shortens startup time in a terminal, but the window title and clipboard will not be used.

When you try the same with xterm it Just WorksTM (it does not have such feature).

1
  • Interesting. I've found what you have here for gvim in the vim manual page. However, There is some sort of difference in my build, or this is broken, because starting gvim with the -X flag does not prevent these other X11 sockets. I guess I'm still looking. Commented Feb 6, 2016 at 0:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .