1

I have a linux box that when I login with ssh, both the keystroke Ctrl-C and manually sending SIGINT will directly terminates the session.

λ> ssh root@rhel74
Last login: Sun Mar 18 21:08:02 2018 from 10.84.40.182
rhel74:~ # ^CConnection to rhel74 closed.
λ> ssh root@rhel74
Last login: Sun Mar 18 21:11:38 2018 from 10.84.40.182
rhel74:~ # ps -ef | grep bash
root     132203 132199  0 21:11 pts/0    00:00:00 -bash
root     132246 132203  0 21:11 pts/0    00:00:00 grep --color=auto bash
rhel74:~ # kill -2 132203
Connection to rhel74 closed.

trap shows that SIGINT is handled by exit. And if a separate shell is spawned, SIGINT will work as expected.

rhel74:~ # trap
trap -- 'exit' SIGINT
trap -- 'exit' SIGTERM
trap -- '' SIGTSTP
trap -- '' SIGTTIN
trap -- '' SIGTTOU
rhel74:~ # bash
rhel74:~ # trap
trap -- '' SIGTSTP
trap -- '' SIGTTIN
trap -- '' SIGTTOU
rhel74:~ # ^C

But what actually determines the default trap handlers for a shell? How to change the behaviour that Ctrl-C quits my ssh session?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.