19

I'm using iTerm2 on Mac OSX (10.10.5).

Recently I encounter something very strange: after using iTerm2 for a while, Ctrl-C would stop working. Initially it was fine. Only after a certain period of usage. The terminal would print out ^C as if it were a normal key press.

I have no idea how this could be reproduced.

3
  • 1
    I'm seeing the same thing. Any luck wih this problem? Nov 16, 2017 at 21:11
  • 2
    I'm starting to think that this is a zsh problem.
    – lang2
    Feb 1, 2018 at 1:59
  • Also see this SO question. I spent a long time trying to understand why I couldn't receive control-c from iTerm2... at first I thought it was a python problem... only later realizing that control-c under iTerm2 seems to be broken... other terminals (such as hyper, kitty done have this problem) Sep 11, 2021 at 22:07

3 Answers 3

5

One of the possible causes for this is that you've used trap to set the INT signal to something else.

If you reset the trap(ed function) on INT to default, this problem should go away1. You can do that by doing this:

trap - INT
trap

One other way to fix this, although "hacky", is to add something like the following to your .zshrc or .bashrc:

function reset_trap {
  # Hacky hack because of <function/script-that-sets-trap-INT>
  trap - INT
}

autoload -Uz add-zsh-hook
add-zsh-hook preexec reset_trap

1 At least, that/this worked for me!

2

I'm posting a work around here as it might benefit some people. I will not accept it myself though.

When this happens, kill the running process in the current tab, probably from a different tab/shell. Then in the original tab, execute reset and things will get back to normal.

Still don't know why.

1
  • reset worked for me, thanks! May 11 at 15:17
0

This happened to me and it was because I had set up CTRL+C as a Global shortcut in Zoom. So, it only was an issue when I was in a Zoom meeting.

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.