Getting a useful persistent VNC session

December 22, 2007

By a persistent VNC session, I mean a session that you can connect your VNC viewer to, do stuff, disconnect from, and then later come back to connect to it again. This makes it the graphical equivalent of screen, at least for me.

(Much like screen, it also gives you a certain amount of immunity against network and workstation stability problems for critical tasks that you don't want interrupted. More and more, systems have to be managed graphically instead of through text interfaces, which means that screen isn't good enough.)

VNC generally comes with a program, vncserver, that starts and manages VNC sessions, and it even puts them in the background for you. The magic secret to useful persistent VNC sessions is simple: ignore this backgrounding and always start vncserver with nohup, because vncserver's backgrounding is only doing half the necessary job.

If you don't do this, what happens can be confusing: once you close the terminal window or log out or whatever from the shell that you ran vncserver, all of the client programs get disconnected from the server, so when you (re)connect to the VNC session all you see is the plain black and white X background.

(Specifically, vncserver just uses '&' in the shell to start things in the background, which doesn't protect them from getting a SIGHUP when the session exits, and the VNC X server itself reacts to SIGHUP by terminating all of the current client connections.)

Update: Pete Zaitcev pointed out in email that people who use normal shells won't see this problem and should just use plain vncserver, without nohup et al. The problem happens for me because I'm using a shell that doesn't do job control.

Written on 22 December 2007.
« A thought about Solaris 10 x86's boot process
Shortening hostnames for fun and profit »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Sat Dec 22 23:25:12 2007
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.