1

I seem to have a peculiar issue with MacOS Terminal (or iTerm) from time to time and I cannot pinpoint the cause.

Whenever I need to kill a program in Terminal, Control + C doesn't work. Terminal simply outputs ^Z for every Control + C.

^Z^Z^Z^Z^Z^Z^Z
^Z^Z
^Z^Z^Z
^Z^Z^Z

It's not limited to Control + C:

  • I get ^X for Control + X
  • ^C for Control + C
  • And so on.

It happens from time to time. Sometimes it's working, then it's not, then it's back again working.

What I've tried:

  • Removed almost all Keyboard shortcuts that start with Control. I've left only those that start with Control + F.

  • Keyboard Viewer does the same (ie. ^Z).

  • Modifier Keys are the default ones.

  • Tried to switch between apps to determine if an app may "hijack" the Control key, but I cannot pinpoint if that's the cause and if so, what's that app (ie. Chrome, TextMate, Notes.app).

  • Output of stty -a:

lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl
    -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
    -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8
    -ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
    -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
    eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
    min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
    stop = ^S; susp = ^Z; time = 0; werase = ^W;```
Max
  • 71
  • 5

3 Answers3

1

What is your output for stty -a from terminal?

You're looking for intr = ^C;

This may be helpful: Ctrl-C and Ctrl-Z not working in terminal

1

I was able to pinpoint the issue further more.

It happens only when I'm SSH-ing into a server and it happens only if I hit Ctrl+Z first to interrupt the program.

If I use Ctrl+C first, it works; if I use Ctrl+Z and then Ctrl+C, it no longer works (the entire program is no longer getting any input).

I guess I'll just leave it like that.

Other findings that might help others:

  • ShortcutDetective app [1] helps only if the issue is locally (ie. app that "steals" your shortcut).

  • There's was a bug reported related to tail or cat & Bash version v3.2.48(1)-release [2].

  • Since Catalina ships with zsh, I've tried to use the latest version of zsh from homebrew rather than the one installed with Catalina.

    % zsh --version
    zsh 5.7.1 (x86_64-apple-darwin19.0)
    
    % brew info zsh
    zsh: stable 5.8 (bottled), HEAD
    
    % brew install zsh
    [...]
    ==> Pouring zsh-5.8.catalina.bottle.tar.gz
      /usr/local/Cellar/zsh/5.8: 1,531 files, 13.7MB
    
  • Another thread [3] reported that the issue may be from rvm so I uninstalled it completely as I wasn't using it.

    % rvm version
    rvm 1.25.15 (stable)
    

[1] https://apple.stackexchange.com/questions/104074/find-which-process-receives-a-given-keyboard-command

[2] Mac OS Terminal - keyboard echo breaks after ctrl-c with some applications

[3] ^C not working in zsh on Mac OSX

Max
  • 71
  • 5
0

This is an extremely long standing issue with macOS, incredibly irritating and very easy to reproduce:

  1. Open a new Terminal.app window running zsh.
  2. Open vim with a file, eg “vim /etc/passwd”
  3. Move the cursor by pressing the down arrow (not “j” - the down arrow)
  4. Suspend vim with Ctrl-Z
  5. Type Ctrl-C

It seems to be a combination of zsh (from Apple or from Homebrew, makes no difference) and macOS Terminal.app - other terminal apps seem OK, and I have reproduced this on a new machine so it's nothing to do with third-party applications.

While I haven't found a solution, to make Ctrl-C work again after it has happened, in the terminal run:

trap -

File an issue with Apple, I have. Hopefully if enough complain it will get fixed.

Mike B
  • 101