iterm2: Ctrl-C doesn't work sometimes

14

2

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.

lang2

Posted 2017-02-15T04:11:26.733

Reputation: 1 830

1I'm seeing the same thing. Any luck wih this problem? – Charlie Dalsass – 2017-11-16T21:11:13.800

2I'm starting to think that this is a zsh problem. – lang2 – 2018-02-01T01:59:07.990

Answers

2

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!

Marco

Posted 2017-02-15T04:11:26.733

Reputation: 121

1

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.

lang2

Posted 2017-02-15T04:11:26.733

Reputation: 1 830