I'm struggling with not working CTRL+C in a certain environment shell command line (CentOS 7 / Vagrant guest of Windows host). I use bash there. The OS, seem, does not matter.

Example run sleep 1000 and press the ctrl-c:

$ sleep 1000

So, it's typing ^C and that's it.

^C is bound for the interruption.

$ stty -a
intr = ^C; ... 

How to make it work?

In the following post, where I was inspired to fix it, the answer explains a lot but does not give a simple answer on how to make it work.
Why didn't Ctrl-C work?
It seems it's a simple thing that I'm struggling with.

  • What do you mean CTRL-C didn't work? Are you running a binary from the command line? Are you developing a script or prorgam and are asking how to trap the interrupt? Please elaborate on exactly what isn't working and give us a use case so we can better help you.
    – mikem
    Sep 13, 2020 at 1:40
  • @mikem No, just command line, shell. I use bash It does not work for interacting a running script nor when you type and hit ctrl-c and it resets you to a new line. So, just shell CLI. If you got some idea how to explain it better, feel free to edit, plz.
    – Kirby
    Sep 13, 2020 at 11:03
  • In my case Ctrl-Shift-C has become the way to stop a program.
    – user527366
    May 26 at 19:32

2 Answers 2


As mentioned in How can we set up a signal trap to be SIG_IGN and SIG_DFL in bash? the simple solution is:

trap - INT

Just add this code into ~/.bashrc for bash, for example.

I decided not to find the root of the cause but just fix it.

Another interesting post: Remove ^C when CTRL+C

  • Interesting.. bash reads the following files on startup: /etc/profile ~/.bash_profile ~/.bashrc ~/.inputrc ... it this fixes smth similar for you, then my guess somewhere in there the INT trap gets unregistered there.
    – user56452
    Sep 13, 2020 at 19:46
  • @user56452, yeah, I was playing with these files by cleaning them. The same. Maybe not all of them... But at least the solution overrides it.
    – Kirby
    Sep 14, 2020 at 12:03

It sounds like maybe a key-mappιng problem.

At the shell prompt, type:

stty sane

and then try to use CTRL-C to stop a command. If it still doesn't work, add the output from:

stty -a

to your question. The stty -a command will list your current terminal line settings. The item of interest is called intr. If intr is set incorrectly, CTRL-C won't work.

If intr is set incorrectly, you can try resetting it with:

stty intr CTRL-V-C

What that means is you type stty intr, then a space and then hold down the CTRL key and press v and then c with no spaces or or other characters between them.

After that, try to stop a command with CTRL-C again and see what the results are.

  • No, it's bind. I have intr = ^C after command stty -a. So, it's not about binding.
    – Kirby
    Sep 13, 2020 at 18:06
  • Can you stop any program with CTRL-C at all? For example, if you run "sleep 10000", can you stop it with CTRL-C?
    – mikem
    Sep 13, 2020 at 18:18
  • No, just mentioned this in the question. But it started working after the command in my answer.
    – Kirby
    Sep 13, 2020 at 18:19
  • Thanks for your answer, but that's not where I'm stuck.
    – Kirby
    Sep 13, 2020 at 18:21

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.