28

This happened many times.

While the SSH active, I'm so tired and just close the terminal without exit

Is it dangerous to doing like that?

2
  • Simply hit Ctrl+D twice instead of Alt-F4 or Ctrl-Q, this sends the exit signal to your current ssh, then to your shell, and the terminal emulator should close automatically without shell. Problem solved.
    – Profpatsch
    Mar 15, 2013 at 11:00
  • @Profpatsch: unless, of course, you use IGNOREEOF (in bash) because you also use a terminal multiplexer and got tired of sometimes mistyping ^a d as ^d, thereby quitting unintentionally. Mar 15, 2013 at 13:02

3 Answers 3

34

Not at all. When the terminal process exits, the client processes within will also die, and when this happens, the connection to the remote server will be closed by the operating system. The server will see the connection close, and terminate the processes on the server.

However, it is possible that you might end up with lingering processes on the server if they were backgrounded and ignore certain signals.

11

When we closes the terminal directly, It generates a SIGHUP signal. This signal kills all the tasks/processes under the terminal automatically/instantly. So no problem occurring.

-1

This may not be true. If bash is running a loop, it can ignore SIGHUP and continue the session. I'm currently trying to work out why this happens.

Also, the shutdown process is noted very well here but apparently Systemd has changed some behaviours.

https://serverfault.com/questions/463366/does-getting-disconnected-from-an-ssh-session-kill-your-programs

2
  • It would be better if you validated your claim first before answering, rather than answering with "this may not be true".
    – Kusalananda
    Jan 12, 2018 at 11:32
  • Well it all depends. It seems to be different between: * Init system settings * Shell settings * Processes being run in the terminal and their signal handling Jan 12, 2018 at 11:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .