On the impossibility to use escape sequences when the networks hangs
Damien Miller
djm at mindrot.org
Thu Oct 16 12:42:12 AEDT 2025
On Thu, 16 Oct 2025, Steffen Nurpmeso wrote:
> Or, you know, if the input queue grows and cannot be sent out, and
> i then start hitting ^C, aka (would) create SIGINT through the
> keyboard, then echo "i hear you master, i do not place this SIGINT
> in the queue, but if you now use an escape, i'll dig it as that".
> And i would say "thank you" in turn.
> Just an idea...
That's not how any of this works unfortunately.
^c is just a character when the terminal is in raw mode. It is sent
to the server and, if it receives it, it may choose to interpret it
as requesting a SIGINT be sent to the session group leader process.
There is zero special handling of ^c in the ssh client.
This always requires 1) that the server receive the ^c, 2) that the
server acts on it and 3) that the results of the server's action
make it back to the client. In a connection that has been interrupted
at the network level then 1 and 2 may not be true.
~. is the mechanism that is supposed to be guaranteed to work in this
situation.
If you need another way to terminate a stuck connection that can't
use the escape character, consider using multiplexing. This will
let you do stuff like "ssh -O exit -S /path/mux.sock host" to
externally terminate a connection without having to look up the
PID of the ssh process.
-d
More information about the openssh-unix-dev
mailing list