A problem with iterm2, latest issue
I have a program that did run on iterm2 but since the last update it no longer works. Now the program just dies and exits. The program does work on xterm. This is on mac latest version mojave.
Here is the program that now does not work. When ran this program will tell you what key is pressed, this includes control keys like ctrl A, ctrl B etc. To exit the program you just enter the letter q.
Here is the program:
/********** the program *************/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
struct termios orig_termios;
void disableRawMode() {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}
void enableRawMode() {
tcgetattr(STDIN_FILENO, &orig_termios);
atexit(disableRawMode);
struct termios raw = orig_termios;
raw.c_lflag &= ~(ECHO | ICANON);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}
int main() {
enableRawMode();
char c;
while (read(STDIN_FILENO, &c, 1) == 1 && c != 'q') {
if (iscntrl(c)) {
printf("%d\n", c);
} else {
printf("%d ('%c')\n", c, c);
}
}
return 0;
}
/*************** end **********/
Edited by George Nachman