Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm developing with vi over ssh.

My problem is that sometimes I get my ssh connection killed because of my poor wifi connection and previous processes (like "top", "rails c", etc...) are not being killed properly.

So after a little while, i get those processes at 100% of the CPU usage (i don't really know why), and I need to kill them manually.

Because I'm not the only developer, it can get really messy so my boss asked me to come up with a solution.

How would i do this?

share|improve this question

3 Answers 3

There are several ways around this:

  1. Kill the leftover processes.
  2. Use something to compensate for the disconnections.

The second option is the easiest with screen or tmux.

After your connection has dropped you reconnect, log back in and resume your screen/tmux session, then continue working where you left. (For screen use screen -r to resume).

If you ever used remote desktop in windows, then you can compare this with resuming a disconnected RDP session.

share|improve this answer
    
I also use screen in such situations as well. Good answer. +1. –  Michał Šrajer Jul 31 '12 at 14:57
    
Can you tell me how to kill the leftover processes? –  boby lapointe Aug 1 '12 at 13:42
    
First get the process ID of the leftover process. Use can use a command such as ps for this. Then use 'kill -1 processID. This will send the process a SIGHUP. Loosely translated this will tell the process "User has disconnected. Please end yourself in a proper way'. Most programs which receive this signal will save files, close databases etc. If that fails use kill -15 or kill -9 (-15 is terminate to the process. Like -1 but more insistent. -15 is not sent to the process but to the OS. It is a 'kill with prejeduce' command which might leave a mess. –  Hennes Aug 1 '12 at 13:48
    
thanks but i meant automatically. –  boby lapointe Aug 1 '12 at 14:32
    
You probably can't do this automatically. The dropped [WiFi] connection should already have caused the shell on the other and to signal all processes with SIGHUP before terminating itself. –  Hennes Aug 1 '12 at 14:55

If you are using ssh with an unreliable connection, you may want to give mosh a try: http://mosh.mit.edu/

Mosh was exactly written for this purpose. Note that you need it installed on both sides.

share|improve this answer
up vote 0 down vote accepted

ssh -t Seems to work as I wanted.

share|improve this answer
    
Care to elaborate? –  aefxx Aug 14 at 8:46

Your Answer

 
discard

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.