These are usually not enabled by default, either by the client or the server, and there are typically two flavors: application level and TCP based (i.e. The user attempting to write to the PTY on the client side (client->server). In this particular context, the factors most likely to trigger a write are:Ī process (typically the one in the foreground) attempting to write to the PTY on the server side (server->client). This will happen quickly if either side attempts to write to the socket and the TCP packets are not acknowledged, or slowly if neither side is attempting to write to the PTY. This is behavior which is specific to every implementation of a SSH daemon, but you can count on all of them to terminate when either side resets the TCP connection. It was requested that I elaborate on "how long it takes for the SSH daemon to decide that your connection is dead". tmux and screen are the more popular ones syntax for using them is beyond the scope of your question, but they're worth looking into. They allow you to detach from your shell processes in a way that you can reattach to them later, regardless of whether that disconnection was accidental or deliberate. Terminal multiplexers are a common way of keeping your shell environment intact between disconnections. The processes that survive a hangup of the controlling terminal are ones that either disassociated themselves from having a terminal (daemon processes that you started inside of it), or ones that were invoked with a prefixed nohup command. If those jobs have jobs of their own, the signal will often get passed along as well. Each of those processes, in turn, will do whatever they're configured to do on receipt of that signal. This notifies the shell that you've vanished and that it should begin cleaning up after itself what happens at this point is shell specific (search its documentation page for "HUP"), but for the most part it will start sending SIGHUP to running jobs associated with it before terminating. When the SSH daemon process associated with your connection decides that your connection is dead, it sends a hangup signal (SIGHUP) to the login shell. You can observe this with the pstree command. Every program you start normally at that point, no matter how many layers of shells deep, will ultimately "trace its ancestry" back to that shell. When you logged in, the SSH daemon allocated a pseudo-terminal for you and attached it to your user's configured login shell. What follows is a longer explanation that will help you understand how it actually works. It depends on how long it takes for the SSH daemon to decide that your connection is dead. They will get killed, but not necessarily immediately. The text below describes how things have traditionally worked in UNIX designspace for longer than Linux has existed. Those mechanisms are outside the scope of this question. The behavior can be changed by setting KillUserProcesses=no in /etc/systemd/nf, or circumvented using the systemd-specific mechanisms for starting a daemon in userspace. As of systemd v230, the new default is to kill all children of a terminating login session, regardless of what historically valid precautions were taken to prevent this. This Q&A predates the systemd v230 debacle. Does getting disconnected from an SSH session kill your programs?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |