[Gllug] Disconnected ssh sessions and pseudo-terminals
damion.yates at gmail.com
damion.yates at gmail.com
Tue Oct 28 13:31:40 UTC 2008
On Tue, 28 Oct 2008, Ziya Suzen wrote:
> Sometimes I hate my ADSL provider. Connections keep dropping and I
> loose my SSH connections.
Have you tried looking at ssh keepalive options? I've had sessions open
for weeks without issue with mine. You could change ISPs. Or perhaps a
VPN to your shell account can retain an virtual interface and IP despite
crumbling underlying 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
I suspect /dev/pts/<anything> corresponds to your current virtual
terminal. You'll need to dig around in /proc/<its PID>/fd/* perhaps to
echo to the right thing. Actually in there you should be able to cat
the contents of those file-descriptors to somewhere safe and examine
them, they should contain your file.
Not that this is likely to work.
> (Note:key combination typed for escape: ctrl+v, Esc)
>
> Any ideas?
If it's vim* sending a kill -1 (SIGHUP) should get it to close reasonably
cleanly. You should also be able to vi it and see the state of the file
via its swap file. You're faced with multiple options:
Found a swap file by the name ".example.txt.swp"
owned by: damion dated: Tue Oct 28 13:26:22 2008
file name: ~damion/example.txt
modified: no
user name: damion host name: aa.secret.domain.com
process ID: 10985 (still running)
While opening file "example.txt"
Swap file ".example.txt.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:
*Or even if it's not, most vi versions deal well with a hangup signal,
old SunOS boxes I used in the past would email me the file in that
situation :)
> And hopelessly tried 'screen' to get to the orphan terminal :(
I love screen and use it all the time. I would rate it as the best
application I have ever used in the world ever!
You need to start screen first and learn to use its power. Then you'd
be able to recover from a dropped connection trivially.
In some rare and oldendays circumstances you could attach in to a
processes ttys, but this is a bug not a thing to recover vi sessions.
Good luck,
Damion
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list