Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mosh should disconnect when remote is rebooted #480

Closed
uzytkownik opened this issue Dec 23, 2013 · 8 comments
Closed

Mosh should disconnect when remote is rebooted #480

uzytkownik opened this issue Dec 23, 2013 · 8 comments

Comments

@uzytkownik
Copy link

When I use ssh and reboot remote a message displaying that remote is rebooted is displayed and ssh session is terminated. mosh needs to be terminated manually.

It would be nice to send the disconnection signal to client when server is being terminated.

@keithw
Copy link
Member

keithw commented Dec 23, 2013

Generally speaking, Mosh already does this (just tested with a Debian server).

if it's not working for you, please make sure that your server is sending the kill signal to all processes (including your mosh-servers) before cutting the network. (Also let us know the OS of your server.)

@keithw keithw closed this as completed Dec 23, 2013
@uzytkownik
Copy link
Author

It did not worked for me on Gentoo (both server and client) with mosh 1.2.4 while it worked with ssh.

@keithw
Copy link
Member

keithw commented Dec 23, 2013

You'll have to take this up with Gentoo -- it needs to send a kill signal (like SIGTERM) to all processes before cutting networking. That's how mosh-server knows it needs to quit.

@uzytkownik
Copy link
Author

Sorry for late reply. I have been thought about it a bit and I guess problem should occur at least on all systemd+netctl systems and probably on systemd+NetworkManager (which are probably all Linux distributions but Debian/Ubuntu currently - and Debian's folks talking about moving to Upstart or systemd).

As far as I can tell the correct signal is SIGHUP:

   SIGHUP        1       Term    Hangup detected on controlling terminal or death of controlling process

Which is sent by systemd but is ignored by the mosh.

@keithw
Copy link
Member

keithw commented Jan 7, 2014

LSB (ISO/IEC 23360) requires that shutdown (and shutdown -r) send SIGTERM, not SIGHUP. We can patch mosh-server to work around this, but please take this up with systemd. And please submit a pull request -- we'd be eager to merge it if systemd is moving in this direction.

@keithw keithw reopened this Jan 7, 2014
@uzytkownik
Copy link
Author

(Sorry - I realized I spoke too soon. sshd reacts to SIGHUP while mosh does not but it's not the issue).

After a thought - the ssh displays a message about shutting down while mosh does not. It looks like mosh is terminating uncleanly and too soon (I guess?). Yay for debugging shutdown issues.

I'll investigate further.

@eminence
Copy link
Member

I just tested this on a fresh install of Debian 9 (aka Debian Stretch), which defaults to using systemd these days, as well as my gentoo machine. In both cases, the mosh-client exited cleanly, with no need to manually terminate anything. So now that this appears fixed, I'm going to close this issue.

@cgull
Copy link
Member

cgull commented Aug 28, 2017

I have made a couple of changes over time that should cause mosh-server to more robustly terminate the client on a server shutdown in some cases. If you are still having problems here, and your SSH sessions do terminate promptly and cleanly, please comment here.

(There are still occasionally systems that bring down their network connectivity before user sessions are closed. That is a different problem which should be addressed at the OS/configuration level.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants