Reading this question got me to wondering. Assuming screen is not being used. If an SSH session on a Linux target is dropped, for whatever reason, and you reconnect before the server kills the session because of timeout, is it possible to regain control of the running command such that it will not be aborted because of the broken session?
|
|
|||||||||||
|
|
Attempting to connect a new terminal's current STD* file descriptors to an old running process is just asking for trouble. Even if you do manage to do that, the terminal's job control won't work as expected. You'll have a mess left behind if you eventually exit the taken-over program, and what happens to the shell that sacrificed its file descriptors to be handed to the newly-backgrounded process. Will ssh stay open when that shell goes away? Probably not. So you'll need to redirect it somewhere else first. Possible or not, I'd wager that it's more desirable to just let the abandoned process get killed "naturally". If you're doing anything important enough to justify trying to do all the hackery required to resume control and you're on an unstable link, you should probably know that in advance and just use screen (or vnc, or whatever floats your detached-control boat). :) |
|||
|
|
Probably not. I cannot guarantee that it is impossible but I really doubt it. One thing is the lack of killing the shell and possible commands running as a consequence of the termination of the ssh connection. This is not so difficult, you should be able to use nohup and similar mechanisms like mentioned in the other question. But then, assume that you started
|
|||
|
|
There was a link to some hacky tty stealing code in this question. You should theoretically be able to use this to regain control of a nohup process. |
|||||
|
|
retty might be able to help you, but the disclaimers are very real and relevant :) |
|||
|
|
|
Generally, the right way to handle this is to prepare for it ahead of time, using GNU If you aren't using
Now, you'd have to tweak this process for your situation. I doubt it would help if you haven't managed to disown the process. If you're using |
|||
|
|
|
If session is droped, it means TTL is already expired, so there is no more tty for you (as I understand it). But, if your network connection is disrupted, your SSH session might not need to go down, and you should be able to resume your connection and continue. Is that what you are asking about? |
|||||
|