[Gllug] Disconnected ssh sessions and pseudo-terminals

Lesley Binks lesleyb at pgcroft.net
Tue Oct 28 12:44:22 UTC 2008


On Tue, Oct 28, 2008 at 11:20:18AM +0000, Alistair Mann wrote:
> Ziya Suzen wrote:
> > Hi there
> > 
> > Sometimes I hate my ADSL provider. Connections keep dropping
> > and I loose my SSH connections. What I usually do is to ignore
> > them and open new SSH sessions. However it gets annoying
> > when you have an editor already opened on a file, you 'ps' it
> > and see it opened there, but you can't exit the editor (vi) or take
> > control of the now not-used pts.
> > 
> > I have tried a few tricks without any luck:
> > 
> > Exit the Editor:
> >  # echo -n ^[ >> /dev/pts/1
> >  # echo -n :x >> /dev/pts/1
> > 
> > (Note:key combination typed for escape: ctrl+v, Esc)
> > 
> > And hopelessly tried 'screen' to get to the orphan terminal :(
> > 
> > Any ideas?
> 
> Vi will gracefully terminate if you send it a signal:
> 
> $ kill -SIGHUP <process id>
> 
> Graceful includes preserving whatever's in the editor but unsaved.
> 
> That help?

'vi -r <filename>' will help recover any edits after a termination.
The trick is to write out what you recover to a temporary file and then
diff against your existing file to see if there are any differences.
Remember to delete the .swp file once you have recovered.

vi and vim write changes out to a swap file which is of the form
.<filename>.swp .  You can see this file with an 'ls -a'.  If one
already exists for the file you want to edit the .swo extension will be
used instead and you will get a warning that the file is already open.

Regards

Lesley
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list