#include #include #include /* Please compile with: * * gcc -W -Wall -o termex termex.c * * The program will wait for you to enter something, * and dump back what you have entered. So please * input some and let the program prints. */ int main (void) { struct termios oldtty, newtty; /* backup */ tcgetattr (0, &oldtty); /* change to non-canonical mode */ tcgetattr (0, &newtty); newtty.c_lflag &= (~ICANON); /* block until one character is read */ newtty.c_cc[VMIN] = 1; newtty.c_cc[VTIME] = 0; tcsetattr (0, TCSANOW, &newtty); /* read something */ unsigned char buf[100]; size_t n = read (0, buf, sizeof(buf)); /* dump what is entered */ printf ("\nread %d bytes: ", n); size_t i; for (i=0; i