Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After running X programs over SSH, SSH doesn't terminate after shell exit (have to use e.g. CtrlC to kill it).

My guess is although the X program already exit, there is still some "connection" left (not freed). The exceptions I have found now are gtk-demo and acroread.

Does anyone know the reason? Is this a problem with ssh{,d} configuration?

share|improve this question
You can test this for yourself. Run ssh with -v and it will report X11 connections that are opened and closed. – Kyle Jones Feb 6 '12 at 18:26
@KyleJones THX, seems that this is the problem (two "connections" freed after C-c is pressed). – yuyichao Feb 6 '12 at 18:37
I`ve got the same problem on SLES11 with any X11-window. How did you trace to down to dbus? – Nils Feb 7 '12 at 20:55
You can simply check the process running as you (if there is no other active sessions). I use systemd and has enabled it in sshd (pam setting), so all the process in the ssh session is in the same cgroup, which makes it really easy to check.~~ – yuyichao Feb 7 '12 at 21:01
up vote 3 down vote accepted

Starting the X program probably starts a background process that doesn't terminate when you close the program (or the program itself doesn't terminate properly). See here for an explanation of what happens.

To fix this, you can try to find out what processes are still running and either prevent them from being started when you log in via SSH or simply kill them before you log out. You can certainly just kill the SSH connection once you have logged out as well though.

share|improve this answer
K, the problem is dbus(gconf) process is still running. (thanks to systemd-cgls~~) (I tried to killall -KILL the program itself thinking it might fork some background process before but that doesn't seems the case.). So is there a way to do things well? (e.g. kill dbus(gconf) automatically) THX – yuyichao Feb 6 '12 at 18:42
You could put killall dbus or something like that in your .logout, but that would probably mess up other things (i.e. when you're logged in locally). – Lars Kotthoff Feb 6 '12 at 19:00
Hmm, seems I need to do this manually (i.e. no direct option for that). At least I am already using kill-session=1 and hopefully systemd can tell me which is the right process to kill (i.e. not killing processes in other sessions.)~~~ THX – yuyichao Feb 6 '12 at 19:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.