25 #include <sys/types.h>
36 perror(
"tcsetattr: ");
43 static int initialized;
51 if(tcgetattr(STDIN_FILENO, &term_attribs) < 0)
53 perror(
"tcgetattr: ");
65 term_attribs.c_lflag &= ~(ECHO | ICANON | ISIG | IEXTEN);
66 term_attribs.c_iflag &= ~(IXON | BRKINT | INPCK | ICRNL | ISTRIP);
67 term_attribs.c_cflag &= ~(CSIZE | PARENB);
68 term_attribs.c_cflag |= CS8;
69 term_attribs.c_cc[VTIME] = 0;
70 term_attribs.c_cc[VMIN] = 0;
72 if(tcsetattr(STDIN_FILENO, TCSANOW, &term_attribs) < 0)
74 perror(
"tcsetattr: ");
82 FD_SET(STDIN_FILENO, &rfds);
83 memset(&tv, 0,
sizeof(tv));
85 retcode = select(1, &rfds, NULL, NULL, &tv);
86 if(retcode == -1 && errno == EINTR)
95 else if(FD_ISSET(STDIN_FILENO, &rfds))
109 FD_SET(STDIN_FILENO, &rfds);
111 retcode = select(1, &rfds, NULL, NULL, NULL);
112 if(retcode == -1 && errno == EINTR)
static struct termios term_attribs term_attribs_old
static void restore_term(void)