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;```
7
  • Terminal is the only application where you've noticed a strange keyboard behavior? Did you install any app at all that helps customize keyboard shortcuts, such as Maestro, or some other older app like Rocket Ship or QuickSilver?
    – user1019780
    Mar 26, 2020 at 15:58
  • I did install Spectacle app that can organize windows, I've uninstalled it and I get the same behavior after a restart.
    – Max
    Mar 29, 2020 at 19:59
  • Maybe the kext and .plist have been left behind during your uninstall and someone still interfere with your keyboard. You should try to reinstall Spectacle, then uninstall it completely using AppRemover (here: macupdate.com/app/mac/42895/mac-malware-remover). It'll get rid of the leftovers for you. Reboot your Mac when done and tell us how it goes.
    – user1019780
    Mar 29, 2020 at 21:14
  • I've uninstalled Spectacle and I'll have a look at that Remover but it's seems to be quite old for Catalina.
    – Max
    Apr 1, 2020 at 9:07
  • I checked, and though AppRemover was developped for older versions of OS X (back then), it is still compatible with macOS. The good thing with AppRemover is that it does a thorough job at uninstalling apps. It leaves no leftovers, while drag-dropping your app to the Trash DOES leave files behind.
    – user1019780
    Apr 1, 2020 at 9:17

2 Answers 2

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

4
  • intr = ^C; is show in stty -a. I've tested it when Ctrl + C worked and when it didn't, it had intr = ^C;.
    – Max
    Mar 29, 2020 at 20:00
  • I've just run across this, perhaps it will help: apple.stackexchange.com/questions/104074/…. Mar 30, 2020 at 19:05
  • I'm looking into that, I've got some errors from dtrace that I need to disable first to begin the hunt. I've also discovered that the Control + C doesn't work only when I'm SSH-into into a server, but locally works 100% of the times I've tested.
    – Max
    Apr 1, 2020 at 9:08
  • Thanks. 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. If I use Ctrl+C first, it works; if I use Ctrl+Z and then Ctrl+C`, it no longer works. I'll just leave it like that.
    – Max
    Apr 2, 2020 at 13:31
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

1
  • Logically, all of that makes sense. Ctrl+Z suspends the current foreground process, where, by definition, it does not receive input, including a Ctrl+C. A suspended foreground process can be resumed in the background with the bg command or in the foreground with fg command. Apr 2, 2020 at 21:57

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.