When I start an SSH session that executes a long-running command, what happens with Ctrl+C (SIGINT) handling?
I can see that the SSH session is closed, but I am not sure who gets the SIGINT first: is it...
the remote long-running command? that is, (a) the signal handler in the remote command is called and stops the remote command, (b) the shell that spawned it detects that the command stopped, and stops as well (c) the remote sshd detects the shell stopped, so it closes the connection
the local ssh receives the signal, and closes the connection.
I think that (1) is happening, but want to make sure.
I am also uncertain about what happens with shell handling of SIGINTs in this case. For example, if I ...
ssh remote 'while true ; do sleep 1 ; date ; done'
and Ctrl+C, then the remote connection is dropped. Is there a way to run the remote command under a shell that will stay alive after Ctrl+C? That is, in this case, stop the loop and allow me to keep working on the remote shell?